use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class SerializeItemTestCase method serialize_and_item.
@Test
public void serialize_and_item() throws ParseException {
AndItem andItem = new AndItem();
andItem.addItem(new WordItem("first"));
andItem.addItem(new WordItem("second"));
AndItem deSerialized = serializeThenParse(andItem);
assertThat(getWord(deSerialized.getItem(0)), is("first"));
assertThat(getWord(deSerialized.getItem(1)), is("second"));
assertThat(deSerialized.getItemCount(), is(2));
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class BooleanSearcherTestCase method requireThatQueryWithoutBooleanPropertiesIsUnchanged.
@Test
public void requireThatQueryWithoutBooleanPropertiesIsUnchanged() {
Query q = new Query("");
q.getModel().getQueryTree().setRoot(new WordItem("foo", "otherfield"));
Result r = exec.search(q);
WordItem root = (WordItem) r.getQuery().getModel().getQueryTree().getRoot();
assertEquals("foo", root.getWord());
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class VespaSerializerTestCase method requireThatGroupingRequestsAreSerialized.
@Test
public void requireThatGroupingRequestsAreSerialized() {
Query query = new Query();
query.getModel().getQueryTree().setRoot(new WordItem("foo"));
assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\")", VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a")).addChild(new EachOperation().addOutput(new CountAggregator())));
assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " + "| all(group(attribute(a)) each(output(count())))", VespaSerializer.serialize(query));
newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("b")).addChild(new EachOperation().addOutput(new CountAggregator())));
assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " + "| all(group(attribute(a)) each(output(count()))) " + "| all(group(attribute(b)) each(output(count())))", VespaSerializer.serialize(query));
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class VespaSerializerTestCase method testAnnotatedAndSegment.
@Test
public final void testAnnotatedAndSegment() {
AndSegmentItem andSegment = new AndSegmentItem("abc", true, false);
andSegment.addItem(new WordItem("a", "indexNamePlaceholder"));
andSegment.addItem(new WordItem("b", "indexNamePlaceholder"));
andSegment.setLabel("labeled");
andSegment.lock();
String q = VespaSerializer.serialize(andSegment);
assertEquals("indexNamePlaceholder contains ([{\"origin\": {\"original\": \"abc\", \"offset\": 0, \"length\": 3}, \"andSegmenting\": true}]phrase(\"a\", \"b\"))", q);
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class VespaSerializerTestCase method testEmptyIndex.
@Test
public final void testEmptyIndex() {
Item item = new WordItem("nalle", true);
String q = VespaSerializer.serialize(item);
assertEquals("default contains \"nalle\"", q);
}
Aggregations