use of com.yahoo.prelude.query.parser.AnyParser in project vespa by vespa-engine.
the class RecallSearcher method search.
@Override
public com.yahoo.search.Result search(Query query, Execution execution) {
String recall = query.properties().getString(recallName);
if (recall == null)
return execution.search(query);
AnyParser parser = new AnyParser(ParserEnvironment.fromExecutionContext(execution.context()));
QueryTree root = parser.parse(Parsable.fromQueryModel(query.getModel()).setQuery("foo").setFilter(recall));
String err;
if (root.getRoot() instanceof NullItem) {
err = "Failed to parse recall parameter.";
} else if (!(root.getRoot() instanceof CompositeItem)) {
err = "Expected CompositeItem root node, got " + root.getClass().getSimpleName() + ".";
} else if (hasRankItem(root.getRoot())) {
query.getModel().getQueryTree().setRoot(root.getRoot());
err = "Recall contains at least one rank item.";
} else {
WordItem placeholder = findOrigWordItem(root.getRoot(), "foo");
if (placeholder == null) {
err = "Could not find placeholder workQuery root.";
} else {
updateFilterTerms(root);
CompositeItem parent = placeholder.getParent();
parent.setItem(parent.getItemIndex(placeholder), query.getModel().getQueryTree().getRoot());
query.getModel().getQueryTree().setRoot(root.getRoot());
query.trace("ANDed recall tree with root workQuery node.", true, 3);
return execution.search(query);
}
}
return new Result(query, ErrorMessage.createInvalidQueryParameter(err));
}