Search in sources :

Example 1 with ConfigGetter

use of com.yahoo.config.subscription.ConfigGetter 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 2 with ConfigGetter

use of com.yahoo.config.subscription.ConfigGetter in project vespa by vespa-engine.

the class ParsingTester method createIndexFacts.

/**
 * Returns an unfrozen version of the IndexFacts this will use.
 * This can be used to add new indexes and passing the resulting IndexFacts to the constructor of this.
 */
public static IndexFacts createIndexFacts() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/query/parser/test/parseindexinfo.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    return new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel)

Example 3 with ConfigGetter

use of com.yahoo.config.subscription.ConfigGetter in project vespa by vespa-engine.

the class SplitterJoinerTestCase method testSplitJoin.

@Test
public void testSplitJoin() {
    ConfigGetter<SplitterJoinerDocumentProcessorConfig> getter = new ConfigGetter<>(SplitterJoinerDocumentProcessorConfig.class);
    ConfigGetter<DocumentmanagerConfig> docManGetter = new ConfigGetter<>(DocumentmanagerConfig.class);
    SplitterJoinerDocumentProcessorConfig cfg = getter.getConfig("file:src/test/java/com/yahoo/docproc/util/splitter-joiner-document-processor.cfg");
    DocumentmanagerConfig docManCfg = docManGetter.getConfig("file:src/test/java/com/yahoo/docproc/util/documentmanager.docindoc.cfg");
    SplitterDocumentProcessor splitter = new SplitterDocumentProcessor(cfg, docManCfg);
    DocumentTypeManager manager = splitter.manager;
    /**
     ** Create documents: ***
     */
    Document inner1 = new Document(manager.getDocumentType("docindoc"), "doc:inner:number:one");
    inner1.setFieldValue("name", new StringFieldValue("Donald Duck"));
    inner1.setFieldValue("content", new StringFieldValue("Lives in Duckburg"));
    Document inner2 = new Document(manager.getDocumentType("docindoc"), "doc:inner:number:two");
    inner2.setFieldValue("name", new StringFieldValue("Uncle Scrooge"));
    inner2.setFieldValue("content", new StringFieldValue("Lives in Duckburg, too."));
    Array<Document> innerArray = (Array<Document>) manager.getDocumentType("outerdoc").getField("innerdocuments").getDataType().createFieldValue();
    innerArray.add(inner1);
    innerArray.add(inner2);
    Document outer = new Document(manager.getDocumentType("outerdoc"), "doc:outer:the:only:one");
    outer.setFieldValue("innerdocuments", innerArray);
    /**
     ** End create documents ***
     */
    Processing p = Processing.of(new DocumentPut(outer));
    splitter.process(p);
    assertEquals(2, p.getDocumentOperations().size());
    assertThat(((DocumentPut) (p.getDocumentOperations().get(0))).getDocument(), sameInstance(inner1));
    assertThat(((DocumentPut) (p.getDocumentOperations().get(1))).getDocument(), sameInstance(inner2));
    assertThat(((DocumentPut) (p.getVariable(cfg.contextFieldName()))).getDocument(), sameInstance(outer));
    assertThat(outer.getFieldValue("innerdocuments"), sameInstance(innerArray));
    assertTrue(innerArray.isEmpty());
    JoinerDocumentProcessor joiner = new JoinerDocumentProcessor(cfg, docManCfg);
    joiner.process(p);
    assertThat(p.getDocumentOperations().size(), equalTo(1));
    assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument(), sameInstance(outer));
    assertThat(p.getVariable(cfg.contextFieldName()), nullValue());
    assertThat(outer.getFieldValue("innerdocuments"), sameInstance(innerArray));
    assertThat(innerArray.size(), equalTo(2));
    assertThat(innerArray.get(0), sameInstance(inner1));
    assertThat(innerArray.get(1), sameInstance(inner2));
}
Also used : ConfigGetter(com.yahoo.config.subscription.ConfigGetter) DocumentPut(com.yahoo.document.DocumentPut) SplitterJoinerDocumentProcessorConfig(com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig) Document(com.yahoo.document.Document) Processing(com.yahoo.docproc.Processing) Array(com.yahoo.document.datatypes.Array) DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Test(org.junit.Test)

Example 4 with ConfigGetter

use of com.yahoo.config.subscription.ConfigGetter 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 5 with ConfigGetter

use of com.yahoo.config.subscription.ConfigGetter in project vespa by vespa-engine.

the class StemmingSearcherTestCase method testEmptyIndexInfo.

@Test
public void testEmptyIndexInfo() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/emptyindexinfo.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
    Query q = new Query(QueryTestCase.httpEncode("?query=cars"));
    new Execution(new Chain<Searcher>(new StemmingSearcher(linguistics)), new Execution.Context(null, indexFacts, null, null, linguistics)).search(q);
    assertEquals("cars", q.getModel().getQueryTree().getRoot().toString());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) StemmingSearcher(com.yahoo.prelude.querytransform.StemmingSearcher) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Test(org.junit.Test)

Aggregations

ConfigGetter (com.yahoo.config.subscription.ConfigGetter)8 IndexFacts (com.yahoo.prelude.IndexFacts)4 IndexModel (com.yahoo.prelude.IndexModel)4 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)4 Test (org.junit.Test)4 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)3 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)2 Query (com.yahoo.search.Query)2 Execution (com.yahoo.search.searchchain.Execution)2 Chain (com.yahoo.component.chain.Chain)1 SplitterJoinerDocumentProcessorConfig (com.yahoo.config.docproc.SplitterJoinerDocumentProcessorConfig)1 Processing (com.yahoo.docproc.Processing)1 Document (com.yahoo.document.Document)1 DocumentPut (com.yahoo.document.DocumentPut)1 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)1 DocumentmanagerConfig (com.yahoo.document.config.DocumentmanagerConfig)1 Array (com.yahoo.document.datatypes.Array)1 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)1 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)1 StemmingSearcher (com.yahoo.prelude.querytransform.StemmingSearcher)1