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());
}
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());
}
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());
}
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));
}
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());
}
Aggregations