Search in sources :

Example 1 with QueryValidatingSearcher

use of com.yahoo.prelude.searcher.QueryValidatingSearcher in project vespa by vespa-engine.

the class QueryValidatingSearcherTestCase method testBasic.

public void testBasic() {
    // Setup
    Map<Searcher, Searcher> chained = new HashMap<>();
    Query query = new Query("?query=test");
    Result result = new Result(query);
    result.hits().add(new Hit("ymail://1111111111/AQAAAP7JgwEAj6XjQQAAAO/+ggA=", 950));
    Searcher validator = new QueryValidatingSearcher();
    DocumentSourceSearcher source = new DocumentSourceSearcher();
    chained.put(validator, source);
    source.addResult(query, result);
    // Exercise
    Result returnedResult = doSearch(validator, query, 0, 10, chained);
    // Validate
    assertEquals(1, returnedResult.getHitCount());
    assertNull(returnedResult.hits().getError());
    returnedResult = doSearch(validator, query, 0, 1001, chained);
    assertEquals(0, returnedResult.getConcreteHitCount());
    assertEquals(4, returnedResult.hits().getError().getCode());
    returnedResult = doSearch(validator, query, 1001, 10, chained);
    assertEquals(0, returnedResult.getConcreteHitCount());
    assertEquals(4, returnedResult.hits().getError().getCode());
}
Also used : Hit(com.yahoo.search.result.Hit) Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) QueryValidatingSearcher(com.yahoo.prelude.searcher.QueryValidatingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) QueryValidatingSearcher(com.yahoo.prelude.searcher.QueryValidatingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Result(com.yahoo.search.Result)

Aggregations

QueryValidatingSearcher (com.yahoo.prelude.searcher.QueryValidatingSearcher)1 Query (com.yahoo.search.Query)1 Result (com.yahoo.search.Result)1 Searcher (com.yahoo.search.Searcher)1 Hit (com.yahoo.search.result.Hit)1 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)1 HashMap (java.util.HashMap)1