Search in sources :

Example 6 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class VsmFields method derive.

protected void derive(StreamingDocumentType document, SDField field) {
    if (field.usesStructOrMap()) {
        for (SDField structField : field.getStructFields()) {
            // Recursion
            derive(document, structField);
        }
    } else {
        if (!(field.doesIndexing() || field.doesSummarying() || field.doesAttributing()))
            return;
        StreamingField streamingField = new StreamingField(field);
        addField(streamingField.getName(), streamingField);
        deriveIndices(document, field, streamingField);
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField)

Example 7 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class FieldOperationApplier method apply.

protected void apply(Field field) {
    if (field instanceof SDField) {
        SDField sdField = (SDField) field;
        sdField.applyOperations();
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField)

Example 8 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class FieldOperationApplierForStructs method copyFields.

private void copyFields(SDDocumentType structType, SDDocumentType sdoc) {
    // find all fields in OTHER types that have this type:
    List<SDDocumentType> list = new ArrayList<>();
    list.add(sdoc);
    list.addAll(sdoc.getTypes());
    for (SDDocumentType anyType : list) {
        Iterator<Field> fields = anyType.fieldIterator();
        while (fields.hasNext()) {
            SDField field = (SDField) fields.next();
            DataType structUsedByField = field.getFirstStructRecursive();
            if (structUsedByField == null) {
                continue;
            }
            if (structUsedByField.getName().equals(structType.getName())) {
                // this field is using this type!!
                field.populateWithStructFields(sdoc, field.getName(), field.getDataType(), field.isHeader(), 0);
                field.populateWithStructMatching(sdoc, field.getName(), field.getDataType(), field.getMatching());
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) ArrayList(java.util.ArrayList) DataType(com.yahoo.document.DataType)

Example 9 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class TextMatch method process.

@Override
public void process(boolean validate) {
    for (SDField field : search.allConcreteFields()) {
        if (field.getMatching().getType() != Matching.Type.TEXT)
            continue;
        ScriptExpression script = field.getIndexingScript();
        if (script == null)
            continue;
        DataType fieldType = field.getDataType();
        if (fieldType instanceof CollectionDataType) {
            fieldType = ((CollectionDataType) fieldType).getNestedType();
        }
        if (fieldType != DataType.STRING)
            continue;
        Set<String> dynamicSummary = new TreeSet<>();
        Set<String> staticSummary = new TreeSet<>();
        new IndexingOutputs(search, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(search, field, dynamicSummary, staticSummary);
        MyVisitor visitor = new MyVisitor(dynamicSummary);
        visitor.visit(script);
        if (!visitor.requiresTokenize)
            continue;
        ExpressionConverter converter = new MyStringTokenizer(search, findAnnotatorConfig(search, field));
        field.setIndexingScript((ScriptExpression) converter.convert(script));
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) TreeSet(java.util.TreeSet) CollectionDataType(com.yahoo.document.CollectionDataType) DataType(com.yahoo.document.DataType) CollectionDataType(com.yahoo.document.CollectionDataType) ExpressionConverter(com.yahoo.vespa.indexinglanguage.ExpressionConverter) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Example 10 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class ValidateFieldWithIndexSettingsCreatesIndex method process.

@Override
public void process(boolean validate) {
    if (!validate)
        return;
    Matching defaultMatching = new Matching();
    Ranking defaultRanking = new Ranking();
    for (SDField field : search.allConcreteFields()) {
        if (field.doesIndexing())
            continue;
        if (field.doesAttributing())
            continue;
        if (!field.getRanking().equals(defaultRanking))
            fail(search, field, "Fields which are not creating an index or attribute can not contain rank settings.");
        if (!field.getMatching().equals(defaultMatching))
            fail(search, field, "Fields which are not creating an index or attribute can not contain match settings.");
    }
}
Also used : Matching(com.yahoo.searchdefinition.document.Matching) Ranking(com.yahoo.searchdefinition.document.Ranking) SDField(com.yahoo.searchdefinition.document.SDField)

Aggregations

SDField (com.yahoo.searchdefinition.document.SDField)85 Test (org.junit.Test)33 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)22 Search (com.yahoo.searchdefinition.Search)15 Attribute (com.yahoo.searchdefinition.document.Attribute)11 Index (com.yahoo.searchdefinition.Index)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 ArrayList (java.util.ArrayList)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 Field (com.yahoo.document.Field)6 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)6 ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)5 ArrayDataType (com.yahoo.document.ArrayDataType)4 DataType (com.yahoo.document.DataType)4 DocumentReference (com.yahoo.searchdefinition.DocumentReference)4 RankProfile (com.yahoo.searchdefinition.RankProfile)4 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4