Search in sources :

Example 61 with Searcher

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

the class UserInputTestCase method setUp.

@Before
public void setUp() throws Exception {
    searchChain = new Chain<Searcher>(new MinimalQueryInserter());
    context = Execution.Context.createContextStub(null);
    execution = new Execution(searchChain, context);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Searcher(com.yahoo.search.Searcher) Before(org.junit.Before)

Example 62 with Searcher

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

the class CacheControlSearcherTestCase method testNoHeader.

public void testNoHeader() {
    Chain<Searcher> chain = getSearchChain();
    Query query = new Query("?query=foo&custid=foo");
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
    assertEquals(0, getCacheControlHeaders(result).size());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) CacheControlSearcher(com.yahoo.search.searchers.CacheControlSearcher) Result(com.yahoo.search.Result)

Example 63 with Searcher

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

the class CacheControlSearcherTestCase method testStateWhileRevalidate.

public void testStateWhileRevalidate() {
    Chain<Searcher> chain = getSearchChain();
    Query query = new Query("?query=foo&custid=foo&cachecontrol.staleage=3600");
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
    assertCacheHeaders(new String[] { "stale-while-revalidate=3600" }, getCacheControlHeaders(result));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) CacheControlSearcher(com.yahoo.search.searchers.CacheControlSearcher) Result(com.yahoo.search.Result)

Example 64 with Searcher

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

the class CacheControlSearcherTestCase method testStaleAndMaxAge.

public void testStaleAndMaxAge() {
    Chain<Searcher> chain = getSearchChain();
    Query query = new Query("?query=foo&custid=foo&cachecontrol.maxage=60&cachecontrol.staleage=3600");
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
    assertCacheHeaders(new String[] { "max-age=60", "stale-while-revalidate=3600" }, getCacheControlHeaders(result));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) CacheControlSearcher(com.yahoo.search.searchers.CacheControlSearcher) Result(com.yahoo.search.Result)

Example 65 with Searcher

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

the class CacheControlSearcherTestCase method testInvalidAgeParams.

public void testInvalidAgeParams() {
    Chain<Searcher> chain = getSearchChain();
    try {
        Query query = new Query("?query=foo&custid=foo&cachecontrol.maxage=foo");
        Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
        assertEquals(0, getCacheControlHeaders(result).size());
        fail("Expected exception");
    } catch (NumberFormatException e) {
    // success
    }
    try {
        Query query = new Query("?query=foo&custid=foo&cachecontrol.staleage=foo");
        Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
        assertEquals(0, getCacheControlHeaders(result).size());
        fail("Expected exception");
    } catch (NumberFormatException e) {
    // success
    }
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) CacheControlSearcher(com.yahoo.search.searchers.CacheControlSearcher) Result(com.yahoo.search.Result)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8