Search in sources :

Example 6 with PhrasingSearcher

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());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) AndItem(com.yahoo.prelude.query.AndItem) Searcher(com.yahoo.search.Searcher) PhrasingSearcher(com.yahoo.prelude.querytransform.PhrasingSearcher) WordItem(com.yahoo.prelude.query.WordItem) PhrasingSearcher(com.yahoo.prelude.querytransform.PhrasingSearcher) OrItem(com.yahoo.prelude.query.OrItem) Test(org.junit.Test)

Example 7 with PhrasingSearcher

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());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) PhrasingSearcher(com.yahoo.prelude.querytransform.PhrasingSearcher) PhrasingSearcher(com.yahoo.prelude.querytransform.PhrasingSearcher) PhraseItem(com.yahoo.prelude.query.PhraseItem) Test(org.junit.Test)

Aggregations

PhrasingSearcher (com.yahoo.prelude.querytransform.PhrasingSearcher)7 Query (com.yahoo.search.Query)7 Searcher (com.yahoo.search.Searcher)7 Execution (com.yahoo.search.searchchain.Execution)7 Test (org.junit.Test)7 AndItem (com.yahoo.prelude.query.AndItem)5 WordItem (com.yahoo.prelude.query.WordItem)5 CompositeItem (com.yahoo.prelude.query.CompositeItem)4 OrItem (com.yahoo.prelude.query.OrItem)3 PhraseItem (com.yahoo.prelude.query.PhraseItem)2 Item (com.yahoo.prelude.query.Item)1