Search in sources :

Example 31 with Execution

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

the class BlendingSearcherTestCase method testOnlySecondBackend.

@Test
public void testOnlySecondBackend() {
    BlendingSearcherWrapper searcher = setupFirstAndSecond();
    Query query = new Query("/search?query=banana&search=second");
    Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
    assertEquals(2, result.getHitCount());
    assertEquals(300.0, result.hits().get(0).getRelevance().getScore(), delta);
    assertEquals(100.0, result.hits().get(1).getRelevance().getScore(), delta);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 32 with Execution

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

the class BlendingSearcherTestCase method testNonexistingBackendCausesError.

@Test
public void testNonexistingBackendCausesError() {
    BlendingSearcherWrapper searcher = setupFirstAndSecond();
    Query query = new Query("/search?query=banana&search=nonesuch");
    Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
    assertEquals(0, result.getConcreteHitCount());
    assertNotNull(result.hits().getError());
    ErrorMessage e = result.hits().getError();
    assertEquals("Invalid query parameter", e.getMessage());
// assertEquals("No source named 'nonesuch' to search. Valid sources are [first, second]",
// e.getDetailedMessage());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 33 with Execution

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

the class BlendingSearcherTestCase method testNonexistingBackendsCausesErrorOnFirst.

@Test
public void testNonexistingBackendsCausesErrorOnFirst() {
    // Feel free to change to include all in the detail message...
    BlendingSearcherWrapper searcher = setupFirstAndSecond();
    Query query = new Query("/search?query=banana&search=nonesuch,orsuch");
    Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
    assertEquals(0, result.getConcreteHitCount());
    assertNotNull(result.hits().getError());
    ErrorMessage e = result.hits().getError();
    assertEquals("Invalid query parameter", e.getMessage());
    // TODO: Do not depend on sources order
    assertEquals("4: Invalid query parameter: Could not resolve source ref 'nonesuch'. Could not resolve source ref 'orsuch'. Valid source refs are first, second.", e.toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 34 with Execution

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

the class CollapsePhraseSearcherTestCase method transformQuery.

private String transformQuery(String rawQuery) {
    CollapsePhraseSearcher searcher = new CollapsePhraseSearcher();
    Query query = new Query(rawQuery);
    new Execution(searcher, Execution.Context.createContextStub()).search(query);
    Item newRoot = query.getModel().getQueryTree().getRoot();
    if (newRoot != null)
        return newRoot.toString();
    else
        return null;
}
Also used : PhraseItem(com.yahoo.prelude.query.PhraseItem) CompositeItem(com.yahoo.prelude.query.CompositeItem) Item(com.yahoo.prelude.query.Item) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) CollapsePhraseSearcher(com.yahoo.prelude.querytransform.CollapsePhraseSearcher)

Example 35 with Execution

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

the class NonPhrasingSearcherTestCase method testNoNonPhrasingIfNoOtherPhrases.

@Test
public void testNoNonPhrasingIfNoOtherPhrases() {
    searcher = new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
    Query query = new Query("?query=tudor+vidor");
    new Execution(searcher, Execution.Context.createContextStub()).search(query);
    CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
    assertEquals(2, item.getItemCount());
    assertEquals("tudor", ((WordItem) item.getItem(0)).getWord());
    assertEquals("vidor", ((WordItem) item.getItem(1)).getWord());
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) NonPhrasingSearcher(com.yahoo.prelude.querytransform.NonPhrasingSearcher) Test(org.junit.Test)

Aggregations

Execution (com.yahoo.search.searchchain.Execution)232 Query (com.yahoo.search.Query)184 Result (com.yahoo.search.Result)127 Test (org.junit.Test)123 Searcher (com.yahoo.search.Searcher)88 Chain (com.yahoo.component.chain.Chain)59 IndexFacts (com.yahoo.prelude.IndexFacts)34 Hit (com.yahoo.search.result.Hit)25 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 AndItem (com.yahoo.prelude.query.AndItem)18 WordItem (com.yahoo.prelude.query.WordItem)17 ComponentId (com.yahoo.component.ComponentId)13 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FastHit (com.yahoo.prelude.fastsearch.FastHit)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)13 ArrayList (java.util.ArrayList)12 CompositeItem (com.yahoo.prelude.query.CompositeItem)11