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());
}
}
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);
}
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);
}
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;
}
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);
}
Aggregations