use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project SearchServices by Alfresco.
the class AlfrescoSolrDataModel method getQueryableFields.
public IndexedField getQueryableFields(QName propertyQName, ContentFieldType type, FieldUse fieldUse) {
if (type != null) {
return getIndexedFieldForContentPropertyMetadata(propertyQName, type);
}
IndexedField indexedField = new IndexedField();
PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName);
if ((propertyDefinition == null)) {
indexedField.addField("_dummy_", false, false);
return indexedField;
}
if (!propertyDefinition.isIndexed() && !propertyDefinition.isStoredInIndex()) {
indexedField.addField("_dummy_", false, false);
return indexedField;
}
if (isTextField(propertyDefinition)) {
switch(fieldUse) {
case COMPLETION:
addCompletionFields(propertyDefinition, indexedField);
break;
case FACET:
addFacetSearchFields(propertyDefinition, indexedField);
break;
case FTS:
addFullTextSearchFields(propertyDefinition, indexedField);
break;
case ID:
addIdentifierSearchFields(propertyDefinition, indexedField);
break;
case MULTI_FACET:
addMultiSearchFields(propertyDefinition, indexedField);
break;
case SORT:
addSortSearchFields(propertyDefinition, indexedField);
break;
case STATS:
addStatsSearchFields(propertyDefinition, indexedField);
break;
case SUGGESTION:
if (isSuggestable(propertyQName)) {
indexedField.addField("suggest", false, false);
}
addCompletionFields(propertyDefinition, indexedField);
break;
case HIGHLIGHT:
addHighlightSearchFields(propertyDefinition, indexedField);
break;
}
} else {
indexedField.addField(getFieldForNonText(propertyDefinition), false, false);
}
return indexedField;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project SearchServices by Alfresco.
the class AlfrescoSolrDataModel method getIndexedFieldNamesForProperty.
/**
* Get all the field names into which we must copy the source data
*
* @param propertyQName QName
* @return IndexedField
*/
public IndexedField getIndexedFieldNamesForProperty(QName propertyQName) {
// TODO: Cache and throw on model refresh
IndexedField indexedField = new IndexedField();
PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName);
if ((propertyDefinition == null)) {
return indexedField;
}
if (!propertyDefinition.isIndexed() && !propertyDefinition.isStoredInIndex()) {
return indexedField;
}
DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType();
if (isTextField(propertyDefinition)) {
if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.TRUE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) {
indexedField.addField(getFieldForText(true, true, false, propertyDefinition), true, false);
if (crossLocaleSearchDataTypes.contains(propertyDefinition.getDataType().getName()) || crossLocaleSearchProperties.contains(propertyDefinition.getName())) {
indexedField.addField(getFieldForText(false, true, false, propertyDefinition), false, false);
}
}
if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH || isIdentifierTextProperty(propertyDefinition.getName()))) {
indexedField.addField(getFieldForText(true, false, false, propertyDefinition), true, false);
indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false);
}
if (dataTypeDefinition.getName().equals(DataTypeDefinition.TEXT)) {
if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) {
if (propertyDefinition.isMultiValued() == false) {
indexedField.addField(getFieldForText(false, false, true, propertyDefinition), false, true);
}
} else if (!isIdentifierTextProperty(propertyDefinition.getName())) {
if (propertyDefinition.getFacetable() == Facetable.TRUE) {
indexedField.addField(getFieldForText(false, false, false, propertyDefinition), false, false);
}
}
}
if (dataTypeDefinition.getName().equals(DataTypeDefinition.MLTEXT)) {
if ((propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.FALSE) || (propertyDefinition.getIndexTokenisationMode() == IndexTokenisationMode.BOTH)) {
if (propertyDefinition.isMultiValued() == false) {
indexedField.addField(getFieldForText(true, false, true, propertyDefinition), true, true);
}
}
}
if (isSuggestable(propertyQName)) {
indexedField.addField("suggest_@" + propertyDefinition.getName().toString(), false, false);
}
} else {
indexedField.addField(getFieldForNonText(propertyDefinition), false, false);
}
return indexedField;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project SearchServices by Alfresco.
the class AlfrescoSolrDataModel method getIndexedFieldForContentPropertyMetadata.
public IndexedField getIndexedFieldForContentPropertyMetadata(QName propertyQName, ContentFieldType type) {
IndexedField indexedField = new IndexedField();
PropertyDefinition propertyDefinition = getPropertyDefinition(propertyQName);
if ((propertyDefinition == null)) {
return indexedField;
}
if (!propertyDefinition.isIndexed() && !propertyDefinition.isStoredInIndex()) {
return indexedField;
}
DataTypeDefinition dataTypeDefinition = propertyDefinition.getDataType();
if (dataTypeDefinition.getName().equals(DataTypeDefinition.CONTENT)) {
StringBuilder builder = new StringBuilder();
builder.append(dataTypeDefinition.getName().getLocalName());
builder.append('@');
// TODO wher we support multi value propertis correctly .... builder.append(propertyDefinition.isMultiValued() ? "m" : "s");
builder.append('s');
builder.append("_");
builder.append('_');
switch(type) {
case DOCID:
builder.append("docid");
break;
case ENCODING:
builder.append("encoding");
break;
case LOCALE:
builder.append("locale");
break;
case MIMETYPE:
builder.append("mimetype");
break;
case SIZE:
builder.append("size");
break;
case TRANSFORMATION_EXCEPTION:
builder.append("tr_ex");
break;
case TRANSFORMATION_STATUS:
builder.append("tr_status");
break;
case TRANSFORMATION_TIME:
builder.append("tr_time");
break;
default:
break;
}
builder.append('@');
builder.append(propertyQName);
indexedField.addField(builder.toString(), false, false);
}
return indexedField;
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project SearchServices by Alfresco.
the class MLAnalayserTest method setUp.
@Before
public void setUp() throws Exception {
analyser = new MLAnalayser(mlAnalaysisMode);
PropertyDefinition propDef = Mockito.mock(PropertyDefinition.class);
// AlfrescoStandardAnalyser.class.getName());
when(propDef.resolveAnalyserClassName(any(Locale.class))).thenReturn(StandardAnalyzer.class.getName());
when(dictionaryService.getProperty(any(QName.class))).thenReturn(propDef);
}
use of org.alfresco.service.cmr.dictionary.PropertyDefinition in project SearchServices by Alfresco.
the class Solr4QueryParser method createIsUnsetQuery.
protected Query createIsUnsetQuery(String queryText, AnalysisMode analysisMode, LuceneFunction luceneFunction) throws ParseException {
PropertyDefinition pd = QueryParserUtils.matchPropertyDefinition(searchParameters.getNamespace(), namespacePrefixResolver, dictionaryService, queryText);
if (pd != null) {
ClassDefinition containerClass = pd.getContainerClass();
QName container = containerClass.getName();
String classType = containerClass.isAspect() ? FIELD_ASPECT : FIELD_TYPE;
Query typeQuery = getFieldQuery(classType, container.toString(), analysisMode, luceneFunction);
BooleanQuery.Builder query = new BooleanQuery.Builder();
Query presenceQuery = createTermQuery(FIELD_PROPERTIES, pd.getName().toString());
if (presenceQuery != null) {
query.add(typeQuery, Occur.MUST);
query.add(presenceQuery, Occur.MUST_NOT);
}
return query.build();
} else {
BooleanQuery.Builder query = new BooleanQuery.Builder();
Query presenceQuery = getWildcardQuery(queryText, "*");
if (presenceQuery != null) {
query.add(presenceQuery, Occur.MUST_NOT);
}
return query.build();
}
}
Aggregations