Search in sources :

Example 6 with WordItem

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

the class ParseTestCase method testFakeCJKSegmenting.

@Test
public void testFakeCJKSegmenting() {
    // "first" "second" and "third" are segments in the test language
    Item item = tester.parseQuery("name:firstsecondthird", null, Language.CHINESE_SIMPLIFIED, Query.Type.ANY, TestLinguistics.INSTANCE);
    assertTrue(item instanceof PhraseSegmentItem);
    PhraseSegmentItem phrase = (PhraseSegmentItem) item;
    assertEquals(3, phrase.getItemCount());
    assertEquals("name:first", phrase.getItem(0).toString());
    assertEquals("name:second", phrase.getItem(1).toString());
    assertEquals("name:third", phrase.getItem(2).toString());
    assertEquals("name", ((WordItem) phrase.getItem(0)).getIndexName());
    assertEquals("name", ((WordItem) phrase.getItem(1)).getIndexName());
    assertEquals("name", ((WordItem) phrase.getItem(2)).getIndexName());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) IntItem(com.yahoo.prelude.query.IntItem) OrItem(com.yahoo.prelude.query.OrItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) WordItem(com.yahoo.prelude.query.WordItem) NotItem(com.yahoo.prelude.query.NotItem) PhraseSegmentItem(com.yahoo.prelude.query.PhraseSegmentItem) Test(org.junit.Test)

Example 7 with WordItem

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

the class SubstringTestCase method testTokenLengthAndLowercasing.

@Test
public final void testTokenLengthAndLowercasing() {
    Query q = new Query("/?query=\u0130");
    WordItem root = (WordItem) q.getModel().getQueryTree().getRoot();
    assertEquals("\u0130", root.getRawWord());
}
Also used : Query(com.yahoo.search.Query) WordItem(com.yahoo.prelude.query.WordItem) Test(org.junit.Test)

Example 8 with WordItem

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

the class WashPhrasesTestCase method testPositive1.

@Test
public void testPositive1() {
    AndItem root = new AndItem();
    root.addItem(new WordItem("a"));
    PhraseItem embedded = new PhraseItem();
    embedded.addItem(new WordItem("bcd"));
    root.addItem(embedded);
    root.addItem(new WordItem("e"));
    assertEquals("AND a bcd e", transformQuery(root));
}
Also used : AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) Test(org.junit.Test)

Example 9 with WordItem

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

the class WashPhrasesTestCase method testPositive2.

@Test
public void testPositive2() {
    AndItem root = new AndItem();
    root.addItem(new WordItem("a"));
    CompositeItem embedded = new AndItem();
    embedded.addItem(new WordItem("bcd"));
    CompositeItem phrase = new PhraseItem();
    phrase.addItem(new WordItem("def"));
    embedded.addItem(phrase);
    root.addItem(embedded);
    root.addItem(new WordItem("e"));
    assertEquals("AND a (AND bcd def) e", transformQuery(root));
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) Test(org.junit.Test)

Example 10 with WordItem

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

the class WashPhrasesTestCase method testNegative3.

@Test
public void testNegative3() {
    AndItem root = new AndItem();
    root.addItem(new WordItem("a"));
    CompositeItem embedded = new AndItem();
    embedded.addItem(new WordItem("bcd"));
    CompositeItem phrase = new PhraseItem();
    phrase.addItem(new WordItem("def"));
    phrase.addItem(new WordItem("ghi"));
    embedded.addItem(phrase);
    root.addItem(embedded);
    root.addItem(new WordItem("e"));
    assertEquals("AND a (AND bcd \"def ghi\") e", transformQuery(root));
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) 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