use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class SegmentSubstitutionTestCase method testSubstitutionAndNot.
public void testSubstitutionAndNot() {
Item a = parseQuery("-firstsecond bc");
Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
q.getModel().getQueryTree().setRoot(a);
assertSemantics("+bc -\"first third\"", q);
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class SegmentSubstitutionTestCase method testBasicSubstitution.
public void testBasicSubstitution() {
Item a = parseQuery("firstsecond");
Query q = new Query("?query=ignored&tracelevel=0&tracelevel.rules=0");
q.getModel().getQueryTree().setRoot(a);
assertSemantics("\"first third\"", q);
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class TextSerialize method parse.
public static Item parse(String serializedQuery) {
try {
ItemContext context = new ItemContext();
Object result = new Parser(new StringReader(serializedQuery.replace("'", "\"")), new ItemFormHandler(), context).start();
context.connectItems();
if (!(result instanceof Item)) {
throw new RuntimeException("The serialized query '" + serializedQuery + "' did not evaluate to an Item" + "(type = " + result.getClass() + ")");
}
return (Item) result;
} catch (ParseException e) {
throw new RuntimeException(e);
} catch (TokenMgrError e) {
throw new RuntimeException(e);
}
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class Model method prepareRankFeaturesFromModel.
private void prepareRankFeaturesFromModel(Ranking ranking) {
Item root = getQueryTree().getRoot();
if (root != null) {
List<Item> tagged = setUniqueIDs(root);
addLabels(tagged, ranking);
addConnectivityRankProperties(tagged, ranking);
addSignificances(tagged, ranking);
}
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class Model method addSignificances.
private void addSignificances(List<Item> candidates, Ranking ranking) {
for (Item candidate : candidates) {
TaggableItem t = (TaggableItem) candidate;
if (!t.hasExplicitSignificance())
continue;
String name = "vespa.term." + t.getUniqueID() + ".significance";
ranking.getProperties().put(name, String.valueOf(t.getSignificance()));
}
}
Aggregations