use of com.yahoo.prelude.query.WeightedSetItem in project vespa by vespa-engine.
the class SemanticSearcherTestCase method testWeightedSetItem.
// This test is order dependent. Fix it!!
public void testWeightedSetItem() {
Query q = new Query();
WeightedSetItem weightedSet = new WeightedSetItem("fieldName");
weightedSet.addToken("a", 1);
weightedSet.addToken("b", 2);
q.getModel().getQueryTree().setRoot(weightedSet);
assertSemantics("WEIGHTEDSET fieldName{[1]:\"a\",[2]:\"b\"}", q);
}
use of com.yahoo.prelude.query.WeightedSetItem in project vespa by vespa-engine.
the class LowercasingTestCase method testWeightedSet.
@Test
public void testWeightedSet() {
Query q = new Query();
AndItem root = new AndItem();
WeightedSetItem tmp;
tmp = new WeightedSetItem(BAMSE);
tmp.addToken("AbC", 3);
root.addItem(tmp);
tmp = new WeightedSetItem(TEDDY);
tmp.addToken("dEf", 5);
root.addItem(tmp);
q.getModel().getQueryTree().setRoot(root);
Result r = execution.search(q);
root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot();
WeightedSetItem w0 = (WeightedSetItem) root.getItem(0);
WeightedSetItem w1 = (WeightedSetItem) root.getItem(1);
assertEquals(1, w0.getNumTokens());
assertEquals(1, w1.getNumTokens());
assertEquals("abc", w0.getTokens().next().getKey());
assertEquals("dEf", w1.getTokens().next().getKey());
}
use of com.yahoo.prelude.query.WeightedSetItem in project vespa by vespa-engine.
the class LowercasingTestCase method testDisableLowercasingWeightedSet.
@Test
public void testDisableLowercasingWeightedSet() {
execution = new Execution(new Chain<Searcher>(new VespaLowercasingSearcher(new LowercasingConfig(new LowercasingConfig.Builder().transform_weighted_sets(false)))), Execution.Context.createContextStub(settings));
Query q = new Query();
AndItem root = new AndItem();
WeightedSetItem tmp;
tmp = new WeightedSetItem(BAMSE);
tmp.addToken("AbC", 3);
root.addItem(tmp);
tmp = new WeightedSetItem(TEDDY);
tmp.addToken("dEf", 5);
root.addItem(tmp);
q.getModel().getQueryTree().setRoot(root);
Result r = execution.search(q);
root = (AndItem) r.getQuery().getModel().getQueryTree().getRoot();
WeightedSetItem w0 = (WeightedSetItem) root.getItem(0);
WeightedSetItem w1 = (WeightedSetItem) root.getItem(1);
assertEquals(1, w0.getNumTokens());
assertEquals(1, w1.getNumTokens());
assertEquals("AbC", w0.getTokens().next().getKey());
assertEquals("dEf", w1.getTokens().next().getKey());
}
use of com.yahoo.prelude.query.WeightedSetItem in project vespa by vespa-engine.
the class YqlParser method buildWeightedSet.
@NonNull
private Item buildWeightedSet(OperatorNode<ExpressionOperator> ast) {
List<OperatorNode<ExpressionOperator>> args = ast.getArgument(1);
Preconditions.checkArgument(args.size() == 2, "Expected 2 arguments, got %s.", args.size());
return fillWeightedSet(ast, args.get(1), new WeightedSetItem(getIndex(args.get(0))));
}
use of com.yahoo.prelude.query.WeightedSetItem in project vespa by vespa-engine.
the class WeightedSetItemTestCase method testNegativeWeight.
@Test
public void testNegativeWeight() {
WeightedSetItem ws = new WeightedSetItem("index");
assertEquals(new Integer(-10), ws.addToken("bad", -10));
assertEquals(1, ws.getNumTokens());
assertEquals(new Integer(-10), ws.getTokenWeight("bad"));
}
Aggregations