Search in sources :

Example 21 with Searcher

use of com.yahoo.search.Searcher 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());
}
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) Test(org.junit.Test)

Example 22 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class PhrasingSearcherTestCase method testNoFileNoChange.

@Test
public void testNoFileNoChange() {
    Searcher searcher = new PhrasingSearcher("");
    Query query = new Query();
    AndItem andItem = new AndItem();
    andItem.addItem(new WordItem("no", "anindex"));
    andItem.addItem(new WordItem("such", "anindex"));
    andItem.addItem(new WordItem("phrase", "indexo"));
    OrItem orItem = new OrItem();
    orItem.addItem(new WordItem("habla"));
    orItem.addItem(new WordItem("babla"));
    orItem.addItem(new WordItem("habla"));
    andItem.addItem(orItem);
    query.getModel().getQueryTree().setRoot(andItem);
    new Execution(searcher, Execution.Context.createContextStub()).search(query);
    assertEquals("AND anindex:no anindex:such indexo:phrase (OR habla babla habla)", 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 23 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class PhrasingSearcherTestCase method testNoDetection.

@Test
public void testNoDetection() {
    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("no"));
    andItem.addItem(new WordItem("such"));
    andItem.addItem(new WordItem("phrase"));
    query.getModel().getQueryTree().setRoot(andItem);
    new Execution(searcher, Execution.Context.createContextStub()).search(query);
    assertEquals("AND no such phrase", 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) Test(org.junit.Test)

Example 24 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class FederationTester method addSearchChain.

void addSearchChain(String id, FederationOptions federationOptions, Searcher... searchers) {
    ComponentId searchChainId = ComponentId.fromString(id);
    builder.addSearchChain(searchChainId, federationOptions, Collections.<String>emptyList());
    Chain<Searcher> chain = new Chain<>(searchChainId, searchers);
    registry.register(chain);
}
Also used : Chain(com.yahoo.component.chain.Chain) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Searcher(com.yahoo.search.Searcher) ComponentId(com.yahoo.component.ComponentId)

Example 25 with Searcher

use of com.yahoo.search.Searcher in project vespa by vespa-engine.

the class VespaIntegrationTestCase method testIt.

// TODO: Setup the answering vespa searcher from this test....
public void testIt() {
    if (System.currentTimeMillis() > 0)
        return;
    Chain<Searcher> chain = new Chain<>(new VespaSearcher("test", "example.yahoo.com", 19010, ""));
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=test"));
    assertEquals(23, result.hits().size());
}
Also used : Chain(com.yahoo.component.chain.Chain) VespaSearcher(com.yahoo.search.federation.vespa.VespaSearcher) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) VespaSearcher(com.yahoo.search.federation.vespa.VespaSearcher) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8