Search in sources :

Example 61 with Execution

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

the class NoRankingSearcherTestCase method testSortOnRelevanceDescending.

@Test
public void testSortOnRelevanceDescending() {
    Query q = new Query("?query=a&sorting=%2ba%20-b%20-[rank]&ranking=hello");
    new Execution(s, Execution.Context.createContextStub()).search(q);
    assertEquals("hello", q.getRanking().getProfile());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 62 with Execution

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

the class NoRankingSearcherTestCase method testDoSearch.

@Test
public void testDoSearch() {
    Query q = new Query("?query=a&sorting=%2ba%20-b&ranking=hello");
    assertEquals("hello", q.getRanking().getProfile());
    new Execution(s, Execution.Context.createContextStub()).search(q);
    assertEquals("unranked", q.getRanking().getProfile());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 63 with Execution

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

the class NoRankingSearcherTestCase method testSortOnRelevanceAscending.

@Test
public void testSortOnRelevanceAscending() {
    Query q = new Query("?query=a&sorting=%2ba%20-b%20-[rank]&ranking=hello");
    new Execution(s, Execution.Context.createContextStub()).search(q);
    assertEquals("hello", q.getRanking().getProfile());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 64 with Execution

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

the class ClusterSearcherTestCase method testThatWeCanSpecifyNumHitsAndHitOffsetWhenSorting.

@Test
public void testThatWeCanSpecifyNumHitsAndHitOffsetWhenSorting() {
    Execution ex = createExecution(true);
    String extra = "&restrict=type1,type2&sorting=%2Basc-score";
    com.yahoo.search.Result result = getResult(0, 2, extra, ex);
    assertEquals(3.0, result.hits().asList().get(0).getField("asc-score"));
    assertEquals(4.0, result.hits().asList().get(1).getField("asc-score"));
    assertResult(6, Arrays.asList(3.0, 4.0), getResult(0, 2, extra, ex));
    assertResult(6, Arrays.asList(4.0, 6.0), getResult(1, 2, extra, ex));
    assertResult(6, Arrays.asList(6.0, 7.0), getResult(2, 2, extra, ex));
    assertResult(6, Arrays.asList(7.0, 9.0), getResult(3, 2, extra, ex));
    assertResult(6, Arrays.asList(9.0, 10.0), getResult(4, 2, extra, ex));
    assertResult(6, Arrays.asList(10.0), getResult(5, 2, extra, ex));
    assertResult(6, new ArrayList<>(), getResult(6, 2, extra, ex));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Test(org.junit.Test)

Example 65 with Execution

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

the class ClusterSearcherTestCase method testRequireThatSearchFailsForUndefinedRankProfileWithMultipleDocTypes.

@Test
public void testRequireThatSearchFailsForUndefinedRankProfileWithMultipleDocTypes() {
    Execution execution = createExecution(Arrays.asList("type1", "type2", "type3"), false);
    // "default" rank profile
    Query query = new Query("?query=hello");
    com.yahoo.search.Result result = execution.search(query);
    assertEquals(9, result.getTotalHitCount());
    // specified "default" rank profile
    query = new Query("?query=hello&ranking.profile=default");
    result = execution.search(query);
    assertEquals(9, result.getTotalHitCount());
    // empty rank profile, should fail
    query = new Query("?query=hello&ranking.profile=");
    result = execution.search(query);
    assertEquals(0, result.getTotalHitCount());
    assertEquals(result.hits().getError().getCode(), Error.INVALID_QUERY_PARAMETER.code);
    // invalid rank profile
    query = new Query("?query=hello&ranking.profile=undefined");
    result = execution.search(query);
    assertEquals(0, result.getTotalHitCount());
    assertEquals(result.hits().getError().getCode(), Error.INVALID_QUERY_PARAMETER.code);
    // testprofile is only defined for type1, but should pass as it exists in at least one document type
    query = new Query("?query=hello&ranking.profile=testprofile");
    result = execution.search(query);
    assertEquals(9, result.getTotalHitCount());
    // testprofile is only defined for type1, but should fail when restricting doc types
    query = new Query("?query=hello&ranking.profile=testprofile&restrict=type1,type3");
    result = execution.search(query);
    assertEquals(0, result.getTotalHitCount());
    assertEquals(result.hits().getError().getCode(), Error.INVALID_QUERY_PARAMETER.code);
    // testprofile is only defined for type1, ok if restricted to type1
    query = new Query("?query=hello&ranking.profile=testprofile&restrict=type1");
    result = execution.search(query);
    assertEquals(3, result.getTotalHitCount());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) 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