Search in sources :

Example 86 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class VespaSerializerTestCase method testExoticItemTypes.

@Test
public final void testExoticItemTypes() {
    Item item = MarkerWordItem.createEndOfHost();
    String q = VespaSerializer.serialize(item);
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"$\")", 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) Test(org.junit.Test)

Example 87 with Item

use of com.yahoo.prelude.query.Item 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)

Example 88 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class YqlParserTestCase method getRootWord.

private WordItem getRootWord(String yqlQuery) {
    Item root = parse(yqlQuery).getRoot();
    assertTrue(root instanceof WordItem);
    return (WordItem) root;
}
Also used : WordAlternativesItem(com.yahoo.prelude.query.WordAlternativesItem) ExactStringItem(com.yahoo.prelude.query.ExactStringItem) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) IndexedItem(com.yahoo.prelude.query.IndexedItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) RegExpItem(com.yahoo.prelude.query.RegExpItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) WordItem(com.yahoo.prelude.query.WordItem)

Example 89 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class YqlParserTestCase method testRaw.

@Test
public void testRaw() {
    Item root = parse("select foo from bar where baz contains (\"yoni jo dima\");").getRoot();
    assertTrue(root instanceof WordItem);
    assertFalse(root instanceof ExactStringItem);
    assertEquals("yoni jo dima", ((WordItem) root).getWord());
    root = parse("select foo from bar where baz contains ([{\"grammar\":\"raw\"}]\"yoni jo dima\");").getRoot();
    assertTrue(root instanceof WordItem);
    assertFalse(root instanceof ExactStringItem);
    assertEquals("yoni jo dima", ((WordItem) root).getWord());
    root = parse("select foo from bar where userInput(\"yoni jo dima\");").getRoot();
    assertTrue(root instanceof AndItem);
    AndItem andItem = (AndItem) root;
    assertEquals(3, andItem.getItemCount());
    root = parse("select foo from bar where [{\"grammar\":\"raw\"}]userInput(\"yoni jo dima\");").getRoot();
    assertTrue(root instanceof WordItem);
    assertTrue(root instanceof ExactStringItem);
    assertEquals("yoni jo dima", ((WordItem) root).getWord());
}
Also used : WordAlternativesItem(com.yahoo.prelude.query.WordAlternativesItem) ExactStringItem(com.yahoo.prelude.query.ExactStringItem) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) IndexedItem(com.yahoo.prelude.query.IndexedItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) RegExpItem(com.yahoo.prelude.query.RegExpItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) ExactStringItem(com.yahoo.prelude.query.ExactStringItem) Test(org.junit.Test)

Example 90 with Item

use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.

the class YqlParserTestCase method testWordAlternativesInPhrase.

@Test
public void testWordAlternativesInPhrase() {
    QueryTree x = parse("select * from sources * where" + " foo contains phrase(\"forest\", alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
    Item root = x.getRoot();
    assertSame(PhraseItem.class, root.getClass());
    PhraseItem phrase = (PhraseItem) root;
    assertEquals(2, phrase.getItemCount());
    assertEquals("forest", ((WordItem) phrase.getItem(0)).getWord());
    checkWordAlternativesContent((WordAlternativesItem) phrase.getItem(1));
}
Also used : WordAlternativesItem(com.yahoo.prelude.query.WordAlternativesItem) ExactStringItem(com.yahoo.prelude.query.ExactStringItem) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) IndexedItem(com.yahoo.prelude.query.IndexedItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) RegExpItem(com.yahoo.prelude.query.RegExpItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) QueryTree(com.yahoo.search.query.QueryTree) PhraseItem(com.yahoo.prelude.query.PhraseItem) Test(org.junit.Test)

Aggregations

Item (com.yahoo.prelude.query.Item)116 AndItem (com.yahoo.prelude.query.AndItem)85 CompositeItem (com.yahoo.prelude.query.CompositeItem)82 WordItem (com.yahoo.prelude.query.WordItem)73 PhraseItem (com.yahoo.prelude.query.PhraseItem)66 NotItem (com.yahoo.prelude.query.NotItem)62 RankItem (com.yahoo.prelude.query.RankItem)60 SubstringItem (com.yahoo.prelude.query.SubstringItem)60 Test (org.junit.Test)58 OrItem (com.yahoo.prelude.query.OrItem)57 PrefixItem (com.yahoo.prelude.query.PrefixItem)53 SuffixItem (com.yahoo.prelude.query.SuffixItem)53 IntItem (com.yahoo.prelude.query.IntItem)52 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)51 NullItem (com.yahoo.prelude.query.NullItem)24 Query (com.yahoo.search.Query)22 EquivItem (com.yahoo.prelude.query.EquivItem)14 NearItem (com.yahoo.prelude.query.NearItem)14 ExactStringItem (com.yahoo.prelude.query.ExactStringItem)12 IndexedItem (com.yahoo.prelude.query.IndexedItem)12