Search in sources :

Example 6 with DocumentSourceSearcher

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

the class JuniperSearcherTestCase method createSearchChain.

/**
 * Creates a search chain which always returns a result with one hit containing information given in this
 *
 * @param sdName the search definition type of the returned hit
 * @param content the content of the "dynteaser" field of the returned hit
 */
private Chain<Searcher> createSearchChain(String sdName, String content) {
    JuniperSearcher searcher = new JuniperSearcher(new ComponentId("test"), new QrSearchersConfig(new QrSearchersConfig.Builder()));
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    addResult(new Query("?query=12"), sdName, content, docsource);
    addResult(new Query("?query=12&bolding=false"), sdName, content, docsource);
    return new Chain<Searcher>(searcher, docsource);
}
Also used : Chain(com.yahoo.component.chain.Chain) Query(com.yahoo.search.Query) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) JuniperSearcher(com.yahoo.prelude.searcher.JuniperSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) ComponentId(com.yahoo.component.ComponentId)

Example 7 with DocumentSourceSearcher

use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher 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)

Example 8 with DocumentSourceSearcher

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

the class JSONDebugSearcherTestCase method makeSearchChain.

private Chain<Searcher> makeSearchChain(String content, Searcher dumper) {
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    addResult(new Query(DUMPJSON), content, docsource);
    addResult(new Query(NODUMPJSON), content, docsource);
    return new Chain<>(dumper, docsource);
}
Also used : Chain(com.yahoo.component.chain.Chain) Query(com.yahoo.search.Query) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)

Example 9 with DocumentSourceSearcher

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

the class YqlFieldAndSourceTestCase method setUp.

@Before
public void setUp() throws Exception {
    Query query = new Query("?query=test");
    Result result = new Result(query);
    Hit hit = createHit("lastHit", .1d, FIELD1, FIELD2, FIELD3);
    result.hits().add(hit);
    DocumentSourceSearcher mockBackend = new DocumentSourceSearcher();
    mockBackend.addResult(query, result);
    mockBackend.addSummaryClassByCopy(DEFAULT_SUMMARY_CLASS, Arrays.asList(FIELD1, FIELD2));
    mockBackend.addSummaryClassByCopy(Execution.ATTRIBUTEPREFETCH, Arrays.asList(FIELD2));
    mockBackend.addSummaryClassByCopy(THIRD_OPTION, Arrays.asList(FIELD3));
    DocumentdbInfoConfig config = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(buildDocumentdbArray()));
    searchChain = new Chain<>(new FieldFiller(config), mockBackend);
    context = Execution.Context.createContextStub(null);
    execution = new Execution(searchChain, context);
}
Also used : Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Result(com.yahoo.search.Result) Before(org.junit.Before)

Example 10 with DocumentSourceSearcher

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

the class FieldFilterTestCase method setUp.

@Before
public void setUp() throws Exception {
    Query query = new Query("?query=test");
    Result result = new Result(query);
    Hit hit = createHit("lastHit", .1d, FIELD_A, FIELD_B, FIELD_C);
    result.hits().add(hit);
    DocumentSourceSearcher mockBackend = new DocumentSourceSearcher();
    mockBackend.addResult(query, result);
    searchChain = new Chain<Searcher>(new FieldFilter(), mockBackend);
    context = Execution.Context.createContextStub(null);
    execution = new Execution(searchChain, context);
}
Also used : Hit(com.yahoo.search.result.Hit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Result(com.yahoo.search.Result) Before(org.junit.Before)

Aggregations

DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 Query (com.yahoo.search.Query)13 Result (com.yahoo.search.Result)11 Searcher (com.yahoo.search.Searcher)10 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)8 HashMap (java.util.HashMap)8 Test (org.junit.Test)8 Chain (com.yahoo.component.chain.Chain)3 Hit (com.yahoo.search.result.Hit)3 Execution (com.yahoo.search.searchchain.Execution)3 Before (org.junit.Before)3 ComponentId (com.yahoo.component.ComponentId)1 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)1 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 JuniperSearcher (com.yahoo.prelude.searcher.JuniperSearcher)1 MultipleResultsSearcher (com.yahoo.prelude.searcher.MultipleResultsSearcher)1 QueryValidatingSearcher (com.yahoo.prelude.searcher.QueryValidatingSearcher)1 GroupList (com.yahoo.search.grouping.result.GroupList)1 HitGroup (com.yahoo.search.result.HitGroup)1