use of com.yahoo.prelude.querytransform.PhrasingSearcher in project vespa by vespa-engine.
the class PhrasingSearcherTestCase method testMultiplePhrases.
@Test
public void testMultiplePhrases() {
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("tudor", "someindex"));
andItem.addItem(new WordItem("vidor", "someindex"));
andItem.addItem(new WordItem("vidor", "someindex"));
OrItem orItem = new OrItem();
andItem.addItem(orItem);
orItem.addItem(new WordItem("tudor"));
AndItem andItem2 = new AndItem();
andItem2.addItem(new WordItem("this", "anotherindex"));
andItem2.addItem(new WordItem("is", "anotherindex"));
andItem2.addItem(new WordItem("a", "anotherindex"));
andItem2.addItem(new WordItem("test", "anotherindex"));
andItem2.addItem(new WordItem("tudor", "anotherindex"));
andItem2.addItem(new WordItem("vidor", "anotherindex"));
orItem.addItem(andItem2);
orItem.addItem(new WordItem("vidor"));
query.getModel().getQueryTree().setRoot(andItem);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
assertEquals("AND someindex:tudor someindex:\"tudor vidor\" someindex:vidor (OR tudor (AND anotherindex:\"this is a test\" anotherindex:\"tudor vidor\") vidor)", query.getModel().getQueryTree().getRoot().toString());
}
use of com.yahoo.prelude.querytransform.PhrasingSearcher in project vespa by vespa-engine.
the class PhrasingSearcherTestCase method testPartialPhrasing.
@Test
public void testPartialPhrasing() {
Searcher searcher = new PhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
Query query = new Query("?query=void%20tudor%20vidor%20kanoo");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
assertEquals("void", ((WordItem) item.getItem(0)).getWord());
assertEquals("kanoo", ((WordItem) item.getItem(2)).getWord());
PhraseItem phrase = (PhraseItem) item.getItem(1);
assertEquals(2, phrase.getItemCount());
assertEquals("tudor", phrase.getWordItem(0).getWord());
assertEquals("vidor", phrase.getWordItem(1).getWord());
}
Aggregations