Search in sources :

Example 6 with DocumentdbInfoConfig

use of com.yahoo.prelude.fastsearch.DocumentdbInfoConfig in project vespa by vespa-engine.

the class VdsStreamingSearcherTestCase method testBasics.

@Test
public void testBasics() {
    MockVisitorFactory factory = new MockVisitorFactory();
    VdsStreamingSearcher searcher = new VdsStreamingSearcher(factory);
    ConfigGetter<DocumentdbInfoConfig> getter = new ConfigGetter<>(DocumentdbInfoConfig.class);
    DocumentdbInfoConfig config = getter.getConfig("file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg");
    searcher.init(new SummaryParameters("default"), new ClusterParams("clusterName"), new CacheParams(100, 1e64), config);
    // Magic query values are used to trigger specific behaviors from mock visitor.
    checkError(searcher, "/?query=noselection", "Backend communication error", "Streaming search needs one and only one");
    checkError(searcher, "/?streaming.userid=1&query=parseexception", "Backend communication error", "Failed to parse document selection string");
    checkError(searcher, "/?streaming.userid=1&query=tokenizeexception", "Backend communication error", "Failed to tokenize document selection string");
    checkError(searcher, "/?streaming.userid=1&query=interruptedexception", "Backend communication error", "Interrupted");
    checkError(searcher, "/?streaming.userid=1&query=timeoutexception", "Timed out", "Timed out");
    checkError(searcher, "/?streaming.userid=1&query=illegalargumentexception", "Backend communication error", "Illegal argument");
    checkError(searcher, "/?streaming.userid=1&query=nosummary", "Backend communication error", "Did not find summary for hit with document id");
    checkError(searcher, "/?streaming.userid=1&query=nosummarytofill", "Timed out", "Missing hit summary data for 1 hits");
    checkSearch(searcher, "/?streaming.userid=1&query=oneuserhit", 1, USERDOC_ID_PREFIX);
    checkSearch(searcher, "/?streaming.userid=1&query=oneuserhit&sorting=%2Bsurname", 1, USERDOC_ID_PREFIX);
    checkSearch(searcher, "/?streaming.selection=id.user%3D%3d1&query=twouserhits", 2, USERDOC_ID_PREFIX);
    checkSearch(searcher, "/?streaming.groupname=group1&query=twogrouphitsandoneuserhit", 2, GROUPDOC_ID_PREFIX);
    checkGrouping(searcher, "/?streaming.selection=true&query=onegroupinghit", 1);
}
Also used : DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) Test(org.junit.Test)

Example 7 with DocumentdbInfoConfig

use of com.yahoo.prelude.fastsearch.DocumentdbInfoConfig in project vespa by vespa-engine.

the class DocumentDatabaseTestCase method assertDocumentDBConfigAvailableForStreaming.

private void assertDocumentDBConfigAvailableForStreaming(String mode) {
    final List<String> sds = Arrays.asList("type");
    VespaModel model = new VespaModelCreatorWithMockPkg(vespaHosts, createVespaServices(sds, mode), ApplicationPackageUtils.generateSearchDefinitions(sds)).create();
    DocumentdbInfoConfig dcfg = model.getConfig(DocumentdbInfoConfig.class, "test/search/cluster.test.type");
    assertEquals(1, dcfg.documentdb().size());
    DocumentdbInfoConfig.Documentdb db = dcfg.documentdb(0);
    assertEquals("type", db.name());
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) VespaModel(com.yahoo.vespa.model.VespaModel)

Example 8 with DocumentdbInfoConfig

use of com.yahoo.prelude.fastsearch.DocumentdbInfoConfig 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)

Aggregations

DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)8 Test (org.junit.Test)4 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)3 Query (com.yahoo.search.Query)3 Result (com.yahoo.search.Result)3 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)2 VespaModel (com.yahoo.vespa.model.VespaModel)2 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)2 ComponentId (com.yahoo.component.ComponentId)1 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)1 VipStatus (com.yahoo.container.handler.VipStatus)1 Fs4Config (com.yahoo.container.search.Fs4Config)1 LegacyEmulationConfig (com.yahoo.container.search.LegacyEmulationConfig)1 FS4ResourcePool (com.yahoo.prelude.fastsearch.FS4ResourcePool)1 ClusterConfig (com.yahoo.search.config.ClusterConfig)1 ErrorMessage (com.yahoo.search.result.ErrorMessage)1 Hit (com.yahoo.search.result.Hit)1 Execution (com.yahoo.search.searchchain.Execution)1 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)1 Statistics (com.yahoo.statistics.Statistics)1