Search in sources :

Example 41 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class ExecutionTestCase method testContextCacheSingleLengthSearchChain.

public void testContextCacheSingleLengthSearchChain() {
    IndexFacts[] contextsBefore = new IndexFacts[1];
    IndexFacts[] contextsAfter = new IndexFacts[1];
    List<Searcher> l = new ArrayList<>(1);
    l.add(new ContextCacheSearcher(0, contextsBefore, contextsAfter));
    Chain<Searcher> chain = new Chain<>(l);
    Query query = new Query("?mutatecontext=0");
    new Execution(chain, Execution.Context.createContextStub()).search(query);
    assertEquals(contextsBefore[0], contextsAfter[0]);
    assertSame(contextsBefore[0], contextsAfter[0]);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) ArrayList(java.util.ArrayList)

Example 42 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class SearchChainDispatcherSearcherTestCase method testChainContinuation.

/**
 * Searchers down the chain after SearchChainDispatcher
 * should be executed
 */
@SuppressWarnings("deprecation")
public void testChainContinuation() {
    // Instantiate Name Rewriter
    RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
    HashMap<String, File> fileList = new HashMap<>();
    fileList.put(NameRewriter.NAME_ENTITY_EXPAND_DICT, new File(NAME_ENTITY_EXPAND_DICT_PATH));
    NameRewriter nameRewriter = new NameRewriter(config, fileList);
    // Instantiate Misspell Rewriter
    MisspellRewriter misspellRewriter = new MisspellRewriter();
    // Create market search chain of only misspell rewriter
    Chain<Searcher> marketSearchChain = new Chain<>(US_MARKET_SEARCH_CHAIN, misspellRewriter);
    // Add market search chain to the registry
    SearchChainRegistry registry = new SearchChainRegistry();
    registry.register(marketSearchChain);
    // Instantiate Search Chain Dispatcher Searcher
    SearchChainDispatcherSearcher searchChainDispatcher = new SearchChainDispatcherSearcher();
    // Create a chain containing the dispatcher and the name rewriter
    ArrayList<Searcher> searchers = new ArrayList<>();
    searchers.add(searchChainDispatcher);
    searchers.add(nameRewriter);
    // Create a chain containing only the dispatcher
    Chain<Searcher> mainSearchChain = new Chain<>(searchers);
    Execution execution = new Execution(mainSearchChain, Execution.Context.createContextStub(registry, null));
    new QueryRewriteSearcherTestUtils(execution);
    IntentModel intentModel = new IntentModel(utils.createInterpretation("wills smith", 0.9, true, false), utils.createInterpretation("will smith", 1.0, false, true));
    utils.assertRewrittenQuery("?query=willl+smith&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" + MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" + MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" + NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" + NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true", "query 'OR (AND willl smith) (AND will smith) " + "\"will smith\" \"will smith movies\" " + "\"will smith news\" \"will smith imdb\" " + "\"will smith lyrics\" \"will smith dead\" " + "\"will smith nfl\" \"will smith new movie hancock\" " + "\"will smith biography\"'", intentModel);
}
Also used : Chain(com.yahoo.component.chain.Chain) RewritesConfig(com.yahoo.search.query.rewrite.RewritesConfig) SearchChainRegistry(com.yahoo.search.searchchain.SearchChainRegistry) File(java.io.File)

Example 43 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class ElapsedTimeTestCase method testReportGeneration.

public void testReportGeneration() {
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    runSomeTraffic(t);
    ElapsedTime elapsed = new ElapsedTime();
    elapsed.add(t);
    t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    runSomeTraffic(t);
    elapsed.add(t);
    assertEquals(true, elapsed.hasDetailedData());
    assertEquals("Time use per searcher:" + " first(QueryProcessing(SEARCH: 2 ms), ResultProcessing(SEARCH: 4 ms, FILL: 4 ms)),\n" + "    second(QueryProcessing(SEARCH: 4 ms, FILL: 4 ms), ResultProcessing(SEARCH: 4 ms, FILL: 4 ms)),\n" + "    third(QueryProcessing(SEARCH: 4 ms, FILL: 4 ms), ResultProcessing()).", elapsed.detailedReport());
}
Also used : Chain(com.yahoo.component.chain.Chain) TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) ElapsedTime(com.yahoo.search.statistics.ElapsedTime)

Example 44 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class ElapsedTimeTestCase method testBasicBreakdownFullyWiredIn.

// This test is to make sure the other tests correctly simulate the call
// order into the TimeTracker
public void testBasicBreakdownFullyWiredIn() {
    Chain<? extends Searcher> chain = new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third"));
    Execution exec = new Execution(chain, Execution.Context.createContextStub());
    exec.timer().injectTimeSource(new CreativeTimeSource(SEARCH_TIMESEQUENCE));
    exec.context().setDetailedDiagnostics(true);
    exec.search(new Query());
    SearcherTimer[] searchers = exec.timer().searcherTracking();
    checkTiming(searchers);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) SearcherTimer(com.yahoo.search.statistics.TimeTracker.SearcherTimer)

Example 45 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class ElapsedTimeTestCase method testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain.

public void testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain() {
    Chain<? extends Searcher> chain = new Chain<>(new SecondTestingSearcher(), new UselessSearcher("first"), new UselessSearcher("second"), new AlmostUselessSearcher("third"));
    Execution exec = new Execution(chain, Execution.Context.createContextStub());
    exec.search(new Query());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query)

Aggregations

Chain (com.yahoo.component.chain.Chain)92 Execution (com.yahoo.search.searchchain.Execution)59 Searcher (com.yahoo.search.Searcher)57 Test (org.junit.Test)56 Result (com.yahoo.search.Result)48 Query (com.yahoo.search.Query)47 FeedContext (com.yahoo.feedapi.FeedContext)21 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)21 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)21 ClusterList (com.yahoo.vespaclient.ClusterList)21 Processor (com.yahoo.processing.Processor)17 Request (com.yahoo.processing.Request)10 Response (com.yahoo.processing.Response)10 ComponentId (com.yahoo.component.ComponentId)8 FederationSearcher (com.yahoo.search.federation.FederationSearcher)8 ArrayList (java.util.ArrayList)8 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 Message (com.yahoo.messagebus.Message)7 Hit (com.yahoo.search.result.Hit)7 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6