use of com.yahoo.search.query.QueryTree in project vespa by vespa-engine.
the class QueryCanonicalizerMicroBenchmark method canonicalize.
private void canonicalize() {
AndItem and = new AndItem();
and.addItem(new WordItem("shoe", "prod"));
and.addItem(new WordItem("apparel & accessories", "tcnm"));
RankItem rank = new RankItem();
rank.addItem(and);
for (int i = 0; i < 25; i++) rank.addItem(new WordItem("word" + i, "normbrnd"));
QueryTree tree = new QueryTree(rank);
QueryCanonicalizer.canonicalize(tree);
}
use of com.yahoo.search.query.QueryTree in project vespa by vespa-engine.
the class YqlParser method buildTree.
@NonNull
private QueryTree buildTree(OperatorNode<?> filterPart) {
Preconditions.checkArgument(filterPart.getArguments().length == 2, "Expected 2 arguments to filter, got %s.", filterPart.getArguments().length);
populateYqlSources(filterPart.<OperatorNode<?>>getArgument(0));
OperatorNode<ExpressionOperator> filterExpression = filterPart.getArgument(1);
populateLinguisticsAnnotations(filterExpression);
Item root = convertExpression(filterExpression);
connectItems();
userQuery = null;
return new QueryTree(root);
}
use of com.yahoo.search.query.QueryTree in project vespa by vespa-engine.
the class YqlParserTestCase method testRange.
@Test
public void testRange() {
QueryTree parsed = parse("select foo from bar where range(baz,1,8);");
assertEquals("baz:[1;8]", parsed.toString());
}
use of com.yahoo.search.query.QueryTree in project vespa by vespa-engine.
the class YqlParserTestCase method testRegexp.
@Test
public void testRegexp() {
QueryTree x = parse("select * from sources * where foo matches \"a b\";");
Item root = x.getRoot();
assertSame(RegExpItem.class, root.getClass());
assertEquals("a b", ((RegExpItem) root).stringValue());
}
use of com.yahoo.search.query.QueryTree in project vespa by vespa-engine.
the class AllParser method simplifyUnnecessaryComposites.
// Simplify if there are unnecessary composites due to single elements
protected final Item simplifyUnnecessaryComposites(Item item) {
if (item == null)
return null;
QueryTree root = new QueryTree(item);
QueryCanonicalizer.canonicalize(root);
return root.getRoot() instanceof NullItem ? null : root.getRoot();
}
Aggregations