use of com.yahoo.prelude.query.CompositeItem 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.CompositeItem 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));
}
use of com.yahoo.prelude.query.CompositeItem in project vespa by vespa-engine.
the class PhrasingSearcherTestCase method testTotalPhrasing.
@Test
public void testTotalPhrasing() {
Searcher searcher = new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
Query query = new Query();
AndItem andItem = new AndItem();
andItem.addItem(new WordItem("tudor", "someindex"));
andItem.addItem(new WordItem("vidor", "someindex"));
query.getModel().getQueryTree().setRoot(andItem);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
Item item = ((CompositeItem) query.getModel().getQueryTree().getRoot()).getItem(0);
assertTrue(item instanceof PhraseItem);
PhraseItem phrase = (PhraseItem) item;
assertEquals(2, phrase.getItemCount());
assertEquals("tudor", phrase.getWordItem(0).getWord());
assertEquals("vidor", phrase.getWordItem(1).getWord());
assertEquals("someindex", phrase.getIndexName());
}
use of com.yahoo.prelude.query.CompositeItem in project vespa by vespa-engine.
the class PhrasingSearcherTestCase method testNoPhrasingIfDifferentIndices.
@Test
public void testNoPhrasingIfDifferentIndices() {
Searcher searcher = new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
Query query = new Query();
AndItem andItem = new AndItem();
andItem.addItem(new WordItem("tudor", "someindex"));
andItem.addItem(new WordItem("vidor", "anotherindex"));
query.getModel().getQueryTree().setRoot(andItem);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
assertTrue(item.getItem(0) instanceof WordItem);
WordItem word = (WordItem) item.getItem(0);
assertEquals("tudor", word.getWord());
assertTrue(item.getItem(1) instanceof WordItem);
word = (WordItem) item.getItem(1);
assertEquals("vidor", word.getWord());
}
use of com.yahoo.prelude.query.CompositeItem in project vespa by vespa-engine.
the class PhrasingSearcherTestCase method testPartialPhrasingSuggestOnly.
@Test
public void testPartialPhrasingSuggestOnly() {
Searcher searcher = new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
Query query = new Query("?query=void%20tudor%20vidor%20kanoo&suggestonly=true");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
assertEquals("void", ((WordItem) item.getItem(0)).getWord());
assertEquals("tudor", ((WordItem) item.getItem(1)).getWord());
assertEquals("vidor", ((WordItem) item.getItem(2)).getWord());
assertEquals("kanoo", ((WordItem) item.getItem(3)).getWord());
}
Aggregations