Search in sources :

Example 21 with Attribute

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

the class ValidateFieldTypes method process.

@Override
public void process(boolean validate) {
    if (!validate)
        return;
    String searchName = search.getName();
    Map<String, DataType> seenFields = new HashMap<>();
    search.allFields().forEach(field -> {
        checkFieldType(searchName, "index field", field.getName(), field.getDataType(), seenFields);
        for (Map.Entry<String, Attribute> entry : field.getAttributes().entrySet()) {
            checkFieldType(searchName, "attribute", entry.getKey(), entry.getValue().getDataType(), seenFields);
        }
    });
    for (DocumentSummary summary : search.getSummaries().values()) {
        for (SummaryField field : summary.getSummaryFields()) {
            checkFieldType(searchName, "summary field", field.getName(), field.getDataType(), seenFields);
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) HashMap(java.util.HashMap) Attribute(com.yahoo.searchdefinition.document.Attribute) TensorDataType(com.yahoo.document.TensorDataType) DataType(com.yahoo.document.DataType) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary) Map(java.util.Map) HashMap(java.util.HashMap)

Example 22 with Attribute

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

the class SearchClusterTest method testSdConfigLogical.

@Test
public void testSdConfigLogical() throws IOException, SAXException {
    // sd1
    SDDocumentType sdt1 = new SDDocumentType("s1");
    Search search1 = new Search("s1", null);
    SDField f1 = new SDField("f1", DataType.STRING);
    f1.addAttribute(new Attribute("f1", DataType.STRING));
    f1.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f1"))));
    sdt1.addField(f1);
    search1.addDocument(sdt1);
    // sd2
    SDDocumentType sdt2 = new SDDocumentType("s2");
    Search search2 = new Search("s2", null);
    SDField f2 = new SDField("f2", DataType.STRING);
    f2.addAttribute(new Attribute("f2", DataType.STRING));
    f2.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f2"))));
    sdt2.addField(f2);
    search2.addDocument(sdt2);
    SearchBuilder builder = new SearchBuilder();
    builder.importRawSearch(search1);
    builder.importRawSearch(search2);
    builder.build();
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Attribute(com.yahoo.searchdefinition.document.Attribute) StatementExpression(com.yahoo.vespa.indexinglanguage.expressions.StatementExpression) Search(com.yahoo.searchdefinition.Search) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) AttributeExpression(com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression) Test(org.junit.Test)

Aggregations

Attribute (com.yahoo.searchdefinition.document.Attribute)22 SDField (com.yahoo.searchdefinition.document.SDField)11 Test (org.junit.Test)4 DocumentSummary (com.yahoo.vespa.documentmodel.DocumentSummary)3 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)3 DataType (com.yahoo.document.DataType)2 Field (com.yahoo.document.Field)2 Index (com.yahoo.searchdefinition.Index)2 Search (com.yahoo.searchdefinition.Search)2 ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ArrayDataType (com.yahoo.document.ArrayDataType)1 PositionDataType (com.yahoo.document.PositionDataType)1 TensorDataType (com.yahoo.document.TensorDataType)1 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)1 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)1 BooleanIndexDefinition (com.yahoo.searchdefinition.document.BooleanIndexDefinition)1 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)1 Ranking (com.yahoo.searchdefinition.document.Ranking)1