Search in sources :

Example 81 with SDField

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

the class RankTypeResolver method resolve.

public void resolve() {
    RankType rankType = null;
    if (fields.size() > 0) {
        boolean first = true;
        for (SDField field : fields) {
            if (first) {
                rankType = fields.get(0).getRankType();
                first = false;
            } else if (!field.getRankType().equals(rankType)) {
                deployLogger.log(Level.WARNING, "In field '" + field.getName() + "' " + field.getRankType() + " for index '" + indexName + "' conflicts with " + rankType + " defined for the same index in field '" + field.getName() + "'. Using " + rankType + ".");
                field.setRankType(rankType);
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) RankType(com.yahoo.searchdefinition.document.RankType)

Example 82 with SDField

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

the class ArraysTestCase method testArrayImporting.

@Test
public void testArrayImporting() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/arrays.sd");
    SDField tags = (SDField) search.getDocument().getField("tags");
    assertEquals(DataType.STRING, ((CollectionDataType) tags.getDataType()).getNestedType());
    SDField ratings = (SDField) search.getDocument().getField("ratings");
    assertTrue(ratings.getDataType() instanceof ArrayDataType);
    assertEquals(DataType.INT, ((ArrayDataType) ratings.getDataType()).getNestedType());
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ArrayDataType(com.yahoo.document.ArrayDataType) Test(org.junit.Test)

Example 83 with SDField

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

the class NGramTestCase method testNGram.

@Test
public void testNGram() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/ngram.sd");
    assertNotNull(search);
    SDField gram1 = search.getConcreteField("gram_1");
    assertEquals(Matching.Type.GRAM, gram1.getMatching().getType());
    assertEquals(1, gram1.getMatching().getGramSize());
    SDField gram2 = search.getConcreteField("gram_2");
    assertEquals(Matching.Type.GRAM, gram2.getMatching().getType());
    // Not set explicitly
    assertEquals(-1, gram2.getMatching().getGramSize());
    SDField gram3 = search.getConcreteField("gram_3");
    assertEquals(Matching.Type.GRAM, gram3.getMatching().getType());
    assertEquals(3, gram3.getMatching().getGramSize());
    assertEquals("input gram_1 | ngram 1 | index gram_1 | summary gram_1", gram1.getIndexingScript().iterator().next().toString());
    assertEquals("input gram_2 | ngram 2 | index gram_2", gram2.getIndexingScript().iterator().next().toString());
    assertEquals("input gram_3 | ngram 3 | index gram_3", gram3.getIndexingScript().iterator().next().toString());
    assertFalse(gram1.getNormalizing().doRemoveAccents());
    assertEquals(Stemming.NONE, gram1.getStemming());
    List<String> queryCommands = gram1.getQueryCommands();
    assertEquals(1, queryCommands.size());
    assertEquals("ngram 1", queryCommands.get(0));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 84 with SDField

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

the class AddAttributeTransformToSummaryOfImportedFieldsTest method createSingleImportedField.

private static ImportedFields createSingleImportedField(String fieldName) {
    Search targetSearch = new Search("target_doc", MockApplicationPackage.createEmpty());
    SDField targetField = new SDField("target_field", DataType.INT);
    DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
    ImportedField importedField = new ImportedField(fieldName, documentReference, targetField);
    return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) ImportedField(com.yahoo.searchdefinition.document.ImportedField) SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search) ImportedField(com.yahoo.searchdefinition.document.ImportedField) ImportedFields(com.yahoo.searchdefinition.document.ImportedFields) DocumentReference(com.yahoo.searchdefinition.DocumentReference)

Example 85 with SDField

use of com.yahoo.searchdefinition.document.SDField 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

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