query = searchQuery.addRequiredTerm(field, value, like);
protected void addSearchExpandoKeywords( BooleanQuery searchQuery, SearchContext searchContext, String keywords, String className) throws Exception { ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge( searchContext.getCompanyId(), className); Set<String> attributeNames = SetUtil.fromEnumeration( expandoBridge.getAttributeNames()); for (String attributeName : attributeNames) { UnicodeProperties properties = expandoBridge.getAttributeProperties( attributeName); int indexType = GetterUtil.getInteger( properties.getProperty(ExpandoColumnConstants.INDEX_TYPE)); if (indexType != ExpandoColumnConstants.INDEX_TYPE_NONE) { String fieldName = getExpandoFieldName( searchContext, expandoBridge, attributeName); if (searchContext.isAndSearch()) { searchQuery.addRequiredTerm(fieldName, keywords); } else { searchQuery.addTerm(fieldName, keywords); } } } }
protected void contribute( String attributeName, ExpandoBridge expandoBridge) { UnicodeProperties properties = expandoBridge.getAttributeProperties( attributeName); int indexType = GetterUtil.getInteger( properties.getProperty(ExpandoColumnConstants.INDEX_TYPE)); if (indexType == ExpandoColumnConstants.INDEX_TYPE_NONE) { return; } String fieldName = getExpandoFieldName(attributeName, expandoBridge); boolean like = false; if (indexType == ExpandoColumnConstants.INDEX_TYPE_TEXT) { like = true; } if (_andSearch) { _booleanQuery.addRequiredTerm(fieldName, _keywords, like); } else { _addTerm(_booleanQuery, fieldName, _keywords, like); } }
@Override public QueryFilter createFieldValueQueryFilter( String ddmStructureFieldName, Serializable ddmStructureFieldValue, Locale locale) throws Exception { BooleanQuery booleanQuery = new BooleanQueryImpl(); String[] ddmStructureFieldNameParts = StringUtil.split( ddmStructureFieldName, DDMIndexer.DDM_FIELD_SEPARATOR); DDMStructure structure = _ddmStructureLocalService.getStructure( GetterUtil.getLong(ddmStructureFieldNameParts[2])); String fieldName = StringUtil.replaceLast( ddmStructureFieldNameParts[3], StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(locale)), StringPool.BLANK); if (structure.hasField(fieldName)) { ddmStructureFieldValue = _ddm.getIndexedFieldValue( ddmStructureFieldValue, structure.getFieldType(fieldName)); } booleanQuery.addRequiredTerm( ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE); return new QueryFilter(booleanQuery); }
query = searchQuery.addRequiredTerm(field, value, like);