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());
}
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());
}
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));
}
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));
}
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));
}
Aggregations