Search in sources :

Example 6 with MockBackend

use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.

the class FastSearcherTestCase method testNullQuery.

@Test
public void testNullQuery() {
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
    String query = "?junkparam=ignored";
    Result result = doSearch(fastSearcher, new Query(query), 0, 10);
    ErrorMessage message = result.hits().getError();
    assertNotNull("Got error", message);
    assertEquals("Null query", message.getMessage());
    assertEquals(query, message.getDetailedMessage());
    assertEquals(Error.NULL_QUERY.code, message.getCode());
}
Also used : Query(com.yahoo.search.Query) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 7 with MockBackend

use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.

the class FastSearcherTestCase method testDispatchDotSummaries.

@Test
public void testDispatchDotSummaries() {
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    DocumentdbInfoConfig documentdbConfigWithOneDb = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("testDb").summaryclass(new DocumentdbInfoConfig.Documentdb.Summaryclass.Builder().name("simple").id(7)).rankprofile(new DocumentdbInfoConfig.Documentdb.Rankprofile.Builder().name("simpler").hasRankFeatures(false).hasSummaryFeatures(false))));
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbConfigWithOneDb);
    String query = "?query=sddocname:a&dispatch.summaries";
    Result result = doSearch(fastSearcher, new Query(query), 0, 10);
    ErrorMessage message = result.hits().getError();
    assertNotNull("Got error", message);
    assertEquals("Invalid query parameter", message.getMessage());
    assertEquals("When using dispatch.summaries and your summary/rankprofile require the query,  you need to enable ranking.queryCache.", message.getDetailedMessage());
    assertEquals(Error.INVALID_QUERY_PARAMETER.code, message.getCode());
    query = "?query=sddocname:a&dispatch.summaries&ranking.queryCache";
    result = doSearch(fastSearcher, new Query(query), 0, 10);
    assertNull(result.hits().getError());
    query = "?query=sddocname:a&dispatch.summaries&summary=simple&ranking=simpler";
    result = doSearch(fastSearcher, new Query(query), 0, 10);
    assertNull(result.hits().getError());
}
Also used : Query(com.yahoo.search.Query) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Result(com.yahoo.search.Result) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) ErrorMessage(com.yahoo.search.result.ErrorMessage) Test(org.junit.Test)

Example 8 with MockBackend

use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.

the class FastSearcherTestCase method testSinglePassGroupingIsForcedWithSingleNodeGroups.

@Test
public void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(new SearchCluster.Node("host0", 123, 0)), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
    Query q = new Query("?query=foo");
    GroupingRequest request1 = GroupingRequest.newInstance(q);
    request1.setRootOperation(new AllOperation());
    GroupingRequest request2 = GroupingRequest.newInstance(q);
    AllOperation all = new AllOperation();
    all.addChild(new EachOperation());
    all.addChild(new EachOperation());
    request2.setRootOperation(all);
    assertForceSinglePassIs(false, q);
    fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
    assertForceSinglePassIs(true, q);
}
Also used : Query(com.yahoo.search.Query) TraceNode(com.yahoo.yolean.trace.TraceNode) EachOperation(com.yahoo.search.grouping.request.EachOperation) Execution(com.yahoo.search.searchchain.Execution) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) AllOperation(com.yahoo.search.grouping.request.AllOperation) Test(org.junit.Test)

Example 9 with MockBackend

use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.

the class FastSearcherTestCase method testNoNormalizing.

@Test
public void testNoNormalizing() {
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
    MockFSChannel.setEmptyDocsums(false);
    // Default cache = 100Mb
    assertEquals(100, fastSearcher.getCacheControl().capacity());
    Result result = doSearch(fastSearcher, new Query("?query=ignored"), 0, 10);
    assertTrue(result.hits().get(0).getRelevance().getScore() > 1000);
}
Also used : Query(com.yahoo.search.Query) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)9 Query (com.yahoo.search.Query)8 Test (org.junit.Test)7 Result (com.yahoo.search.Result)6 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)3 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)2 AllOperation (com.yahoo.search.grouping.request.AllOperation)2 EachOperation (com.yahoo.search.grouping.request.EachOperation)2 ErrorMessage (com.yahoo.search.result.ErrorMessage)2 Execution (com.yahoo.search.searchchain.Execution)2 TraceNode (com.yahoo.yolean.trace.TraceNode)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)1 WordItem (com.yahoo.prelude.query.WordItem)1 Ignore (org.junit.Ignore)1