use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class YqlParser method buildPredicate.
@NonNull
private Item buildPredicate(OperatorNode<ExpressionOperator> ast) {
List<OperatorNode<ExpressionOperator>> args = ast.getArgument(1);
Preconditions.checkArgument(args.size() == 3, "Expected 3 arguments, got %s.", args.size());
PredicateQueryItem item = new PredicateQueryItem();
item.setIndexName(getIndex(args.get(0)));
addFeatures(args.get(1), (key, value, subqueryBitmap) -> item.addFeature(key, (String) value, subqueryBitmap), PredicateQueryItem.ALL_SUB_QUERIES);
addFeatures(args.get(2), (key, value, subqueryBitmap) -> {
if (value instanceof Long) {
item.addRangeFeature(key, (Long) value, subqueryBitmap);
} else {
item.addRangeFeature(key, (Integer) value, subqueryBitmap);
}
}, PredicateQueryItem.ALL_SUB_QUERIES);
return leafStyleSettings(ast, item);
}
use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class BooleanSearcherTestCase method requireThatAttributeMapToSingleFeature.
@Test
public void requireThatAttributeMapToSingleFeature() {
PredicateQueryItem item = buildPredicateQueryItem("{gender:female}", null);
assertEquals(1, item.getFeatures().size());
assertEquals(0, item.getRangeFeatures().size());
assertEquals("gender", item.getFeatures().iterator().next().getKey());
assertEquals("female", item.getFeatures().iterator().next().getValue());
assertEquals("PREDICATE_QUERY_ITEM gender=female", item.toString());
}
use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class BooleanSearcherTestCase method requireThatRangeAttributesMapToRangeTerm.
@Test
public void requireThatRangeAttributesMapToRangeTerm() {
PredicateQueryItem item = buildPredicateQueryItem(null, "{age:25}");
assertEquals(0, item.getFeatures().size());
assertEquals(1, item.getRangeFeatures().size());
assertEquals("PREDICATE_QUERY_ITEM age:25", item.toString());
item = buildPredicateQueryItem(null, "{age:25:0x43, height:170:[2,3,4]}");
assertEquals(0, item.getFeatures().size());
assertEquals(2, item.getRangeFeatures().size());
}
use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class BooleanSearcherTestCase method buildPredicateQueryItem.
private PredicateQueryItem buildPredicateQueryItem(String attributes, String rangeAttributes) {
Query q = buildQuery("predicate", attributes, rangeAttributes);
Result r = exec.search(q);
return (PredicateQueryItem) r.getQuery().getModel().getQueryTree().getRoot();
}
use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class BooleanAttributeParserTest method assertException.
private void assertException(String s) {
try {
PredicateQueryItem item = new PredicateQueryItem();
new BooleanSearcher.PredicateValueAttributeParser(item).parse(s);
fail("Expected an exception");
} catch (IllegalArgumentException e) {
}
}
Aggregations