Search in sources :

Example 11 with OrItem

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

the class ParseTestCase method testOrAndSomeTermsFilterAndAnAnd.

// This is an ugly parse tree, but it's at least reasonable
@Test
public void testOrAndSomeTermsFilterAndAnAnd() {
    AndItem root = (AndItem) tester.assertParsed("AND (RANK d |c |a |b |e) (OR |e |f)", "d", "c (a b) e +(e f)", Query.Type.ALL);
    // AND
    assertFalse(root.isFilter());
    // RANK
    assertFalse(root.getItem(0).isFilter());
    // d
    assertFalse(((RankItem) root.getItem(0)).getItem(0).isFilter());
    // c
    assertTrue(((RankItem) root.getItem(0)).getItem(1).isFilter());
    // a
    assertTrue(((RankItem) root.getItem(0)).getItem(2).isFilter());
    // b
    assertTrue(((RankItem) root.getItem(0)).getItem(3).isFilter());
    // e
    assertTrue(((RankItem) root.getItem(0)).getItem(4).isFilter());
    // OR
    assertFalse(root.getItem(1).isFilter());
    // e
    assertTrue(((OrItem) root.getItem(1)).getItem(0).isFilter());
    // f
    assertTrue(((OrItem) root.getItem(1)).getItem(1).isFilter());
}
Also used : AndItem(com.yahoo.prelude.query.AndItem) RankItem(com.yahoo.prelude.query.RankItem) OrItem(com.yahoo.prelude.query.OrItem) Test(org.junit.Test)

Example 12 with OrItem

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

the class ParseTestCase method testPrefixAndWordTerms.

@Test
public void testPrefixAndWordTerms() {
    Item root = tester.assertParsed("OR foo prefix* bar", "foo prefix* bar", Query.Type.ANY);
    assertTrue(((OrItem) root).getItem(1) instanceof PrefixItem);
}
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) PrefixItem(com.yahoo.prelude.query.PrefixItem) OrItem(com.yahoo.prelude.query.OrItem) Test(org.junit.Test)

Aggregations

AndItem (com.yahoo.prelude.query.AndItem)12 OrItem (com.yahoo.prelude.query.OrItem)12 Test (org.junit.Test)12 WordItem (com.yahoo.prelude.query.WordItem)11 PhraseItem (com.yahoo.prelude.query.PhraseItem)8 RankItem (com.yahoo.prelude.query.RankItem)8 Item (com.yahoo.prelude.query.Item)7 NotItem (com.yahoo.prelude.query.NotItem)7 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)7 CompositeItem (com.yahoo.prelude.query.CompositeItem)6 IntItem (com.yahoo.prelude.query.IntItem)6 PrefixItem (com.yahoo.prelude.query.PrefixItem)6 SubstringItem (com.yahoo.prelude.query.SubstringItem)6 SuffixItem (com.yahoo.prelude.query.SuffixItem)6 Query (com.yahoo.search.Query)4 PhrasingSearcher (com.yahoo.prelude.querytransform.PhrasingSearcher)2 Searcher (com.yahoo.search.Searcher)2 Execution (com.yahoo.search.searchchain.Execution)2 EquivItem (com.yahoo.prelude.query.EquivItem)1 NearItem (com.yahoo.prelude.query.NearItem)1