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());
}
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());
}
}
}
}
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());
}
}
}
}
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());
}
}
}
}
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());
}
Aggregations