use of com.yahoo.prelude.query.AndItem in project vespa by vespa-engine.
the class GetRawWordTestCase method testGetRawWord.
@Test
public void testGetRawWord() {
Query query = new Query("?query=%C4%B0%C5%9EBANKASI%20GAZ%C4%B0EM%C4%B0R&searchChain=vespa");
assertEquals("AND \u0130\u015EBANKASI GAZ\u0130EM\u0130R", query.getModel().getQueryTree().toString());
AndItem root = (AndItem) query.getModel().getQueryTree().getRoot();
{
WordItem word = (WordItem) root.getItem(0);
assertEquals("\u0130\u015EBANKASI", word.getRawWord());
assertEquals(0, word.getOrigin().start);
assertEquals(9, word.getOrigin().end);
}
{
WordItem word = (WordItem) root.getItem(1);
assertEquals("GAZ\u0130EM\u0130R", word.getRawWord());
assertEquals(10, word.getOrigin().start);
assertEquals(18, word.getOrigin().end);
}
assertEquals("Total string is just these words", 18, ((WordItem) root.getItem(0)).getOrigin().getSuperstring().length());
}
use of com.yahoo.prelude.query.AndItem in project vespa by vespa-engine.
the class ParseTestCase method testPlusWordWebParsing2.
@Test
public void testPlusWordWebParsing2() {
Item root = tester.assertParsed("AND a b", "+a +b", Query.Type.WEB);
assertTrue(((AndItem) root).getItem(0).isProtected());
assertTrue(((AndItem) root).getItem(1).isProtected());
}
use of com.yahoo.prelude.query.AndItem 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));
}
use of com.yahoo.prelude.query.AndItem 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));
}
use of com.yahoo.prelude.query.AndItem 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));
}
Aggregations