use of com.yahoo.prelude.query.ONearItem in project vespa by vespa-engine.
the class YqlParser method instantiateONearItem.
@NonNull
private Item instantiateONearItem(String field, OperatorNode<ExpressionOperator> ast) {
assertHasFunctionName(ast, ONEAR);
NearItem onear = new ONearItem();
onear.setIndexName(field);
for (OperatorNode<ExpressionOperator> word : ast.<List<OperatorNode<ExpressionOperator>>>getArgument(1)) {
onear.addItem(instantiateWordItem(field, word, onear.getClass()));
}
Integer distance = getAnnotation(ast, DISTANCE, Integer.class, null, "term distance for ONEAR operator");
if (distance != null) {
onear.setDistance(distance);
}
return onear;
}
use of com.yahoo.prelude.query.ONearItem in project vespa by vespa-engine.
the class ItemEncodingTestCase method testONearItemEncoding.
@Test
public void testONearItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
NearItem onear = new ONearItem(7);
onear.addItem(a);
onear.addItem(b);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = onear.encode(buffer);
buffer.flip();
assertEquals("Serialization count", 3, count);
assertType(buffer, 12, 0);
assertEquals("Near arity", 2, buffer.get());
assertEquals("Limit", 7, buffer.get());
assertWord(buffer, "a");
assertWord(buffer, "b");
}
Aggregations