Search in sources :

Example 76 with WordItem

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));
}
Also used : AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) Test(org.junit.Test)

Example 77 with WordItem

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());
}
Also used : Query(com.yahoo.search.Query) WordItem(com.yahoo.prelude.query.WordItem) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 78 with WordItem

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));
}
Also used : EachOperation(com.yahoo.search.grouping.request.EachOperation) Query(com.yahoo.search.Query) CountAggregator(com.yahoo.search.grouping.request.CountAggregator) AllOperation(com.yahoo.search.grouping.request.AllOperation) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) AttributeFunction(com.yahoo.search.grouping.request.AttributeFunction) Test(org.junit.Test)

Example 79 with WordItem

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);
}
Also used : AndSegmentItem(com.yahoo.prelude.query.AndSegmentItem) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) Test(org.junit.Test)

Example 80 with WordItem

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);
}
Also used : AndSegmentItem(com.yahoo.prelude.query.AndSegmentItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) Item(com.yahoo.prelude.query.Item) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) Test(org.junit.Test)

Aggregations

WordItem (com.yahoo.prelude.query.WordItem)93 Test (org.junit.Test)76 AndItem (com.yahoo.prelude.query.AndItem)45 PhraseItem (com.yahoo.prelude.query.PhraseItem)31 Query (com.yahoo.search.Query)25 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)20 CompositeItem (com.yahoo.prelude.query.CompositeItem)18 Item (com.yahoo.prelude.query.Item)17 MarkerWordItem (com.yahoo.prelude.query.MarkerWordItem)16 NotItem (com.yahoo.prelude.query.NotItem)16 OrItem (com.yahoo.prelude.query.OrItem)13 ByteBuffer (java.nio.ByteBuffer)11 PrefixItem (com.yahoo.prelude.query.PrefixItem)10 SubstringItem (com.yahoo.prelude.query.SubstringItem)10 SuffixItem (com.yahoo.prelude.query.SuffixItem)10 Execution (com.yahoo.search.searchchain.Execution)10 RankItem (com.yahoo.prelude.query.RankItem)9 PhraseMatcher (com.yahoo.prelude.querytransform.PhraseMatcher)9 IntItem (com.yahoo.prelude.query.IntItem)8 WeakAndItem (com.yahoo.prelude.query.WeakAndItem)7