Search in sources :

Example 1 with DocumentdbInfoConfig

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

the class DocumentDatabaseTestCase method requireThatRelevantConfigIsAvailableForClusterSearcher.

@Test
public void requireThatRelevantConfigIsAvailableForClusterSearcher() throws ParseException, IOException, SAXException {
    final List<String> sds = Arrays.asList("type1", "type2");
    VespaModel model = new VespaModelCreatorWithMockPkg(vespaHosts, createVespaServices(sds, "index"), ApplicationPackageUtils.generateSearchDefinitions(sds)).create();
    String searcherId = "container/searchchains/chain/test/component/com.yahoo.prelude.cluster.ClusterSearcher";
    {
        // documentdb-info config
        DocumentdbInfoConfig dcfg = model.getConfig(DocumentdbInfoConfig.class, searcherId);
        assertEquals(2, dcfg.documentdb().size());
        {
            // type1
            DocumentdbInfoConfig.Documentdb db = dcfg.documentdb(0);
            assertEquals("type1", db.name());
            assertEquals(6, db.rankprofile().size());
            assertRankProfile(db, 0, "default", false, false);
            assertRankProfile(db, 1, "unranked", false, false);
            assertRankProfile(db, 2, "staticrank", false, false);
            assertRankProfile(db, 3, "summaryfeatures", true, false);
            assertRankProfile(db, 4, "inheritedsummaryfeatures", true, false);
            assertRankProfile(db, 5, "rankfeatures", false, true);
            assertEquals(2, db.summaryclass().size());
            assertEquals("default", db.summaryclass(0).name());
            assertEquals("attributeprefetch", db.summaryclass(1).name());
            assertSummaryField(db, 0, 0, "f1", "longstring", true);
            assertSummaryField(db, 0, 1, "f2", "integer", false);
        }
        {
            // type2
            DocumentdbInfoConfig.Documentdb db = dcfg.documentdb(1);
            assertEquals("type2", db.name());
        }
    }
    {
        // attributes config
        AttributesConfig acfg = model.getConfig(AttributesConfig.class, searcherId);
        assertEquals(4, acfg.attribute().size());
        assertEquals("f2", acfg.attribute(0).name());
        assertEquals("f2_nfa", acfg.attribute(1).name());
        assertEquals("f4", acfg.attribute(2).name());
        assertEquals("f4_nfa", acfg.attribute(3).name());
    }
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) VespaModel(com.yahoo.vespa.model.VespaModel) AttributesConfig(com.yahoo.vespa.config.search.AttributesConfig) Test(org.junit.Test)

Example 2 with DocumentdbInfoConfig

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

the class FastSearcherTestCase method createFastSearcher.

private FastSearcher createFastSearcher() {
    mockBackend = new MockBackend();
    ConfigGetter<DocumentdbInfoConfig> getter = new ConfigGetter<>(DocumentdbInfoConfig.class);
    DocumentdbInfoConfig config = getter.getConfig("file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg");
    MockFSChannel.resetDocstamp();
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    return new FastSearcher(mockBackend, new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), config);
}
Also used : DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) ConfigGetter(com.yahoo.config.subscription.ConfigGetter)

Example 3 with DocumentdbInfoConfig

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

the class FastSearcherTestCase method testQueryWithRestrict.

@Test
public void testQueryWithRestrict() {
    mockBackend = new MockBackend();
    DocumentdbInfoConfig documentdbConfigWithOneDb = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("testDb")));
    FastSearcher fastSearcher = new FastSearcher(mockBackend, new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbConfigWithOneDb);
    Query query = new Query("?query=foo&model.restrict=testDb");
    query.prepare();
    Result result = doSearch(fastSearcher, query, 0, 10);
    Packet receivedPacket = mockBackend.getChannel().getLastQueryPacket();
    byte[] encoded = QueryTestCase.packetToBytes(receivedPacket);
    byte[] correct = new byte[] { 0, 0, 0, 100, 0, 0, 0, -38, 0, 0, 0, 0, 0, 16, 0, 6, 0, 10, // time left
    QueryTestCase.ignored, // time left
    QueryTestCase.ignored, // time left
    QueryTestCase.ignored, // time left
    QueryTestCase.ignored, 0, 0, 0x40, 0x03, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 1, 0, 0, 0, 5, 109, 97, 116, 99, 104, 0, 0, 0, 1, 0, 0, 0, 24, 100, 111, 99, 117, 109, 101, 110, 116, 100, 98, 46, 115, 101, 97, 114, 99, 104, 100, 111, 99, 116, 121, 112, 101, 0, 0, 0, 6, 116, 101, 115, 116, 68, 98, 0, 0, 0, 1, 0, 0, 0, 7, 68, 1, 0, 3, 102, 111, 111 };
    QueryTestCase.assertEqualArrays(correct, encoded);
}
Also used : Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) Test(org.junit.Test)

Example 4 with DocumentdbInfoConfig

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

the class ClusterSearcherTestCase method createSearcher.

private static ClusterSearcher createSearcher(Double maxQueryTimeout, Double maxQueryCacheTimeout) {
    ComponentId id = new ComponentId("test-id");
    QrSearchersConfig qrsCfg = new QrSearchersConfig(new QrSearchersConfig.Builder().searchcluster(new QrSearchersConfig.Searchcluster.Builder().name("test-cluster")));
    ClusterConfig.Builder clusterCfgBld = new ClusterConfig.Builder().clusterName("test-cluster");
    if (maxQueryTimeout != null) {
        clusterCfgBld.maxQueryTimeout(maxQueryTimeout);
    }
    if (maxQueryCacheTimeout != null) {
        clusterCfgBld.maxQueryCacheTimeout(maxQueryCacheTimeout);
    }
    ClusterConfig clusterCfg = new ClusterConfig(clusterCfgBld);
    DocumentdbInfoConfig documentDbCfg = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("type1")));
    LegacyEmulationConfig emulationCfg = new LegacyEmulationConfig(new LegacyEmulationConfig.Builder());
    QrMonitorConfig monitorCfg = new QrMonitorConfig(new QrMonitorConfig.Builder());
    Statistics statistics = Statistics.nullImplementation;
    Fs4Config fs4Cfg = new Fs4Config(new Fs4Config.Builder());
    FS4ResourcePool fs4ResourcePool = new FS4ResourcePool(fs4Cfg);
    ClusterSearcher searcher = new ClusterSearcher(id, qrsCfg, clusterCfg, documentDbCfg, emulationCfg, monitorCfg, new DispatchConfig(new DispatchConfig.Builder()), createClusterInfoConfig(), statistics, fs4ResourcePool, new VipStatus());
    return searcher;
}
Also used : DispatchConfig(com.yahoo.vespa.config.search.DispatchConfig) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) VipStatus(com.yahoo.container.handler.VipStatus) Fs4Config(com.yahoo.container.search.Fs4Config) Statistics(com.yahoo.statistics.Statistics) FS4ResourcePool(com.yahoo.prelude.fastsearch.FS4ResourcePool) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) LegacyEmulationConfig(com.yahoo.container.search.LegacyEmulationConfig) ComponentId(com.yahoo.component.ComponentId) ClusterConfig(com.yahoo.search.config.ClusterConfig)

Example 5 with DocumentdbInfoConfig

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

the class YqlFieldAndSourceTestCase method setUp.

@Before
public void setUp() throws Exception {
    Query query = new Query("?query=test");
    Result result = new Result(query);
    Hit hit = createHit("lastHit", .1d, FIELD1, FIELD2, FIELD3);
    result.hits().add(hit);
    DocumentSourceSearcher mockBackend = new DocumentSourceSearcher();
    mockBackend.addResult(query, result);
    mockBackend.addSummaryClassByCopy(DEFAULT_SUMMARY_CLASS, Arrays.asList(FIELD1, FIELD2));
    mockBackend.addSummaryClassByCopy(Execution.ATTRIBUTEPREFETCH, Arrays.asList(FIELD2));
    mockBackend.addSummaryClassByCopy(THIRD_OPTION, Arrays.asList(FIELD3));
    DocumentdbInfoConfig config = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(buildDocumentdbArray()));
    searchChain = new Chain<>(new FieldFiller(config), mockBackend);
    context = Execution.Context.createContextStub(null);
    execution = new Execution(searchChain, context);
}
Also used : Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Result(com.yahoo.search.Result) Before(org.junit.Before)

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