Search in sources :

Example 51 with PropertyDefinition

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;
}
Also used : PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 52 with PropertyDefinition

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;
}
Also used : DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 53 with PropertyDefinition

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;
}
Also used : DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 54 with PropertyDefinition

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);
}
Also used : Locale(java.util.Locale) QName(org.alfresco.service.namespace.QName) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) Before(org.junit.Before)

Example 55 with PropertyDefinition

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();
    }
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) Query(org.apache.lucene.search.Query) RegexpQuery(org.apache.lucene.search.RegexpQuery) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ConstantScoreQuery(org.apache.lucene.search.ConstantScoreQuery) SpanNearQuery(org.apache.lucene.search.spans.SpanNearQuery) SpanOrQuery(org.apache.lucene.search.spans.SpanOrQuery) MultiTermQuery(org.apache.lucene.search.MultiTermQuery) SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) TermQuery(org.apache.lucene.search.TermQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) TermRangeQuery(org.apache.lucene.search.TermRangeQuery) QName(org.alfresco.service.namespace.QName) Builder(org.apache.lucene.search.BooleanQuery.Builder) ClassDefinition(org.alfresco.service.cmr.dictionary.ClassDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition) Builder(org.apache.lucene.search.BooleanQuery.Builder)

Aggregations

PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)77 QName (org.alfresco.service.namespace.QName)51 HashMap (java.util.HashMap)25 ArrayList (java.util.ArrayList)24 NodeRef (org.alfresco.service.cmr.repository.NodeRef)16 Map (java.util.Map)15 Serializable (java.io.Serializable)14 AssociationDefinition (org.alfresco.service.cmr.dictionary.AssociationDefinition)11 ClassDefinition (org.alfresco.service.cmr.dictionary.ClassDefinition)11 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)9 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)9 Collection (java.util.Collection)7 List (java.util.List)7 AspectDefinition (org.alfresco.service.cmr.dictionary.AspectDefinition)7 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)7 BooleanQuery (org.apache.lucene.search.BooleanQuery)7 Builder (org.apache.lucene.search.BooleanQuery.Builder)7 Constraint (org.alfresco.service.cmr.dictionary.Constraint)6 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)6 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)6