Search in sources :

Example 1 with ClusterSearcher

use of com.yahoo.search.cluster.ClusterSearcher in project vespa by vespa-engine.

the class ClusterSearcherTestCase method testSimple.

public void testSimple() {
    Hit blockingHit = new Hit("blocking");
    Hit nonblockingHit = new Hit("nonblocking");
    BlockingBackendSearcher blockingSearcher = new BlockingBackendSearcher(blockingHit);
    List<Searcher> searchers = new ArrayList<>();
    searchers.add(blockingSearcher);
    searchers.add(new TestingBackendSearcher(nonblockingHit));
    ClusterSearcher<?> provider = new SearcherClusterSearcher(new ComponentId("simple"), searchers, new SimpleHasher<>());
    Result blockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(0));
    assertEquals(blockingHit, blockingResult.hits().get(0));
    Result nonblockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(1));
    assertEquals(nonblockingHit, nonblockingResult.hits().get(0));
    blockingSearcher.setBlocking(true);
    blockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(0));
    assertEquals(blockingResult.hits().get(0), nonblockingHit);
    nonblockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(1));
    assertEquals(nonblockingResult.hits().get(0), nonblockingHit);
}
Also used : PingableSearcher(com.yahoo.search.cluster.PingableSearcher) Searcher(com.yahoo.search.Searcher) ClusterSearcher(com.yahoo.search.cluster.ClusterSearcher) ArrayList(java.util.ArrayList) Result(com.yahoo.search.Result) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) ComponentId(com.yahoo.component.ComponentId)

Aggregations

ComponentId (com.yahoo.component.ComponentId)1 Result (com.yahoo.search.Result)1 Searcher (com.yahoo.search.Searcher)1 ClusterSearcher (com.yahoo.search.cluster.ClusterSearcher)1 PingableSearcher (com.yahoo.search.cluster.PingableSearcher)1 Hit (com.yahoo.search.result.Hit)1 Execution (com.yahoo.search.searchchain.Execution)1 ArrayList (java.util.ArrayList)1