Search in sources :

Example 51 with SDField

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

the class CommentTestCase method testComments.

@Test
public void testComments() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/comment.sd");
    SDField field = search.getConcreteField("a");
    assertEquals("{ input a | tokenize normalize stem:\"SHORTEST\" | summary a | index a; }", field.getIndexingScript().toString());
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 52 with SDField

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

the class PredicateDataTypeTestCase method requireThatBuilderHandlesLongValues.

@Test
public void requireThatBuilderHandlesLongValues() throws ParseException {
    int arity = 2;
    long lowerBound = -100000000000000000L;
    long upperBound = 1000000000000000000L;
    String sd = searchSd(predicateFieldSd(attributeFieldSd(arityParameter(arity) + // +'L'
    "lower-bound: -100000000000000000L\n" + upperBoundParameter(upperBound))));
    SearchBuilder sb = SearchBuilder.createFromString(sd);
    for (SDField field : sb.getSearch().allConcreteFields()) {
        if (field.getDataType() == DataType.PREDICATE) {
            for (Index index : field.getIndices().values()) {
                assertEquals(arity, index.getBooleanIndexDefiniton().getArity());
                assertEquals(lowerBound, index.getBooleanIndexDefiniton().getLowerBound());
                assertEquals(upperBound, index.getBooleanIndexDefiniton().getUpperBound());
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 53 with SDField

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

the class PredicateDataTypeTestCase method requireThatBuilderHandlesMissingParameters.

@Test
public void requireThatBuilderHandlesMissingParameters() throws ParseException {
    String sd = searchSd(predicateFieldSd(attributeFieldSd(arityParameter(2))));
    SearchBuilder sb = SearchBuilder.createFromString(sd);
    for (SDField field : sb.getSearch().allConcreteFields()) {
        if (field.getDataType() == DataType.PREDICATE) {
            for (Index index : field.getIndices().values()) {
                assertEquals(true, index.getBooleanIndexDefiniton().hasArity());
                assertEquals(false, index.getBooleanIndexDefiniton().hasLowerBound());
                assertEquals(false, index.getBooleanIndexDefiniton().hasUpperBound());
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 54 with SDField

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

the class PredicateDataTypeTestCase method requireThatBuilderSetsIndexParametersCorrectly.

@Test
public void requireThatBuilderSetsIndexParametersCorrectly() throws ParseException {
    int arity = 2;
    long lowerBound = -100;
    long upperBound = 100;
    String sd = searchSd(predicateFieldSd(attributeFieldSd(arityParameter(arity) + lowerBoundParameter(lowerBound) + upperBoundParameter(upperBound))));
    SearchBuilder sb = SearchBuilder.createFromString(sd);
    for (SDField field : sb.getSearch().allConcreteFields()) {
        if (field.getDataType() == DataType.PREDICATE) {
            for (Index index : field.getIndices().values()) {
                assertEquals(true, index.getBooleanIndexDefiniton().hasArity());
                assertEquals(arity, index.getBooleanIndexDefiniton().getArity());
                assertEquals(true, index.getBooleanIndexDefiniton().hasLowerBound());
                assertEquals(lowerBound, index.getBooleanIndexDefiniton().getLowerBound());
                assertEquals(true, index.getBooleanIndexDefiniton().hasUpperBound());
                assertEquals(upperBound, index.getBooleanIndexDefiniton().getUpperBound());
            }
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 55 with SDField

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

the class RankProfileTestCase method testRankProfileInheritance.

@Test
public void testRankProfileInheritance() {
    Search search = new Search("test", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("test");
    SDField a = document.addField("a", DataType.STRING);
    a.setRankType(RankType.IDENTITY);
    document.addField("b", DataType.STRING);
    search.addDocument(document);
    RankProfile child = new RankProfile("child", search, rankProfileRegistry);
    child.setInherited("default");
    rankProfileRegistry.addRankProfile(child);
    Iterator<RankProfile.RankSetting> i = child.rankSettingIterator();
    RankProfile.RankSetting setting = i.next();
    assertEquals(RankType.IDENTITY, setting.getValue());
    assertEquals("a", setting.getFieldName());
    assertEquals(RankProfile.RankSetting.Type.RANKTYPE, setting.getType());
    setting = i.next();
    assertEquals(RankType.DEFAULT, setting.getValue());
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) 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