Search in sources :

Example 1 with IndexInfoConfig

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

use of com.yahoo.search.config.IndexInfoConfig in project vespa by vespa-engine.

the class DocumentDatabaseTestCase method requireThatWeCanHaveMultipleSearchDefinitions.

@Test
public void requireThatWeCanHaveMultipleSearchDefinitions() throws IOException, SAXException, ParseException {
    final List<String> sds = Arrays.asList("type1", "type2", "type3");
    VespaModel model = new VespaModelCreatorWithMockPkg(vespaHosts, createVespaServices(sds, "index"), ApplicationPackageUtils.generateSearchDefinitions(sds)).create();
    IndexedSearchCluster indexedSearchCluster = (IndexedSearchCluster) model.getSearchClusters().get(0);
    ContentSearchCluster contentSearchCluster = model.getContentClusters().get("test").getSearch();
    String type1Id = "test/search/cluster.test/type1";
    String type2Id = "test/search/cluster.test/type2";
    String type3Id = "test/search/cluster.test/type3";
    {
        assertEquals(3, indexedSearchCluster.getDocumentDbs().size());
        ProtonConfig proton = getProtonCfg(contentSearchCluster);
        assertEquals(3, proton.documentdb().size());
        assertEquals("type1", proton.documentdb(0).inputdoctypename());
        assertEquals(type1Id, proton.documentdb(0).configid());
        assertEquals("type2", proton.documentdb(1).inputdoctypename());
        assertEquals(type2Id, proton.documentdb(1).configid());
        assertEquals("type3", proton.documentdb(2).inputdoctypename());
        assertEquals(type3Id, proton.documentdb(2).configid());
    }
    assertDocTypeConfig(model, type1Id, "f1", "f2");
    assertDocTypeConfig(model, type2Id, "f3", "f4");
    assertDocTypeConfig(model, type3Id, "f5", "f6");
    {
        IndexInfoConfig iicfg = model.getConfig(IndexInfoConfig.class, "test/search/cluster.test");
        assertEquals(3, iicfg.indexinfo().size());
        assertEquals("type1", iicfg.indexinfo().get(0).name());
        assertEquals("type2", iicfg.indexinfo().get(1).name());
        assertEquals("type3", iicfg.indexinfo().get(2).name());
    }
    {
        AttributesConfig rac1 = model.getConfig(AttributesConfig.class, type1Id);
        assertEquals(2, rac1.attribute().size());
        assertEquals("f2", rac1.attribute(0).name());
        assertEquals("f2_nfa", rac1.attribute(1).name());
        AttributesConfig rac2 = model.getConfig(AttributesConfig.class, type2Id);
        assertEquals(2, rac2.attribute().size());
        assertEquals("f4", rac2.attribute(0).name());
        assertEquals("f4_nfa", rac2.attribute(1).name());
    }
    {
        IlscriptsConfig icfg = model.getConfig(IlscriptsConfig.class, "test/search/cluster.test");
        assertEquals(3, icfg.ilscript().size());
        assertEquals("type1", icfg.ilscript(0).doctype());
        assertEquals("type2", icfg.ilscript(1).doctype());
        assertEquals("type3", icfg.ilscript(2).doctype());
    }
}
Also used : ContentSearchCluster(com.yahoo.vespa.model.content.ContentSearchCluster) ProtonConfig(com.yahoo.vespa.config.search.core.ProtonConfig) IndexedSearchCluster(com.yahoo.vespa.model.search.IndexedSearchCluster) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) IlscriptsConfig(com.yahoo.vespa.configdefinition.IlscriptsConfig) VespaModel(com.yahoo.vespa.model.VespaModel) AttributesConfig(com.yahoo.vespa.config.search.AttributesConfig) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) Test(org.junit.Test)

Example 3 with IndexInfoConfig

use of com.yahoo.search.config.IndexInfoConfig 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)

Example 4 with IndexInfoConfig

use of com.yahoo.search.config.IndexInfoConfig in project vespa by vespa-engine.

the class YqlParserTestCase method testFieldAliases.

@Test
public void testFieldAliases() {
    IndexInfoConfig modelConfig = new IndexInfoConfig(new IndexInfoConfig.Builder().indexinfo(new Indexinfo.Builder().name("music").command(new Command.Builder().indexname("title").command("index")).alias(new Alias.Builder().alias("song").indexname("title"))));
    IndexModel model = new IndexModel(modelConfig, (QrSearchersConfig) null);
    IndexFacts indexFacts = new IndexFacts(model);
    ParserEnvironment parserEnvironment = new ParserEnvironment().setIndexFacts(indexFacts);
    YqlParser configuredParser = new YqlParser(parserEnvironment);
    QueryTree x = configuredParser.parse(new Parsable().setQuery("select * from sources * where title contains \"a\" and song contains \"b\";"));
    List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
    assertEquals(2, terms.size());
    for (IndexedItem term : terms) {
        assertEquals("title", term.getIndexName());
    }
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) IndexedItem(com.yahoo.prelude.query.IndexedItem) Parsable(com.yahoo.search.query.parser.Parsable) IndexModel(com.yahoo.prelude.IndexModel) Alias(com.yahoo.search.config.IndexInfoConfig.Indexinfo.Alias) Indexinfo(com.yahoo.search.config.IndexInfoConfig.Indexinfo) QueryTree(com.yahoo.search.query.QueryTree) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment) Test(org.junit.Test)

Example 5 with IndexInfoConfig

use of com.yahoo.search.config.IndexInfoConfig in project vespa by vespa-engine.

the class IndexCombinatorTestCase method testMixedIndicesAndAttributes.

@Test
public void testMixedIndicesAndAttributes() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/indexcombinator.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    IndexFacts facts = new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
    Result r = new Execution(transformer, Execution.Context.createContextStub(facts)).search(new Query(QueryTestCase.httpEncode("?query=\"a b\"")));
    assertEquals("OR default:\"a b\" attribute1:a b attribute2:a b", r.getQuery().getModel().getQueryTree().getRoot().toString());
    r = new Execution(transformer, Execution.Context.createContextStub(facts)).search(new Query(QueryTestCase.httpEncode("?query=\"a b\" \"c d\"")));
    assertEquals("OR (AND default:\"a b\" default:\"c d\")" + " (AND default:\"a b\" attribute1:c d)" + " (AND default:\"a b\" attribute2:c d)" + " (AND attribute1:a b default:\"c d\")" + " (AND attribute1:a b attribute1:c d)" + " (AND attribute1:a b attribute2:c d)" + " (AND attribute2:a b default:\"c d\")" + " (AND attribute2:a b attribute1:c d)" + " (AND attribute2:a b attribute2:c d)", r.getQuery().getModel().getQueryTree().getRoot().toString());
}
Also used : 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) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)8 IndexModel (com.yahoo.prelude.IndexModel)7 IndexFacts (com.yahoo.prelude.IndexFacts)6 Test (org.junit.Test)6 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)4 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)3 Query (com.yahoo.search.Query)3 Indexinfo (com.yahoo.search.config.IndexInfoConfig.Indexinfo)2 Command (com.yahoo.search.config.IndexInfoConfig.Indexinfo.Command)2 Execution (com.yahoo.search.searchchain.Execution)2 Chain (com.yahoo.component.chain.Chain)1 IndexedItem (com.yahoo.prelude.query.IndexedItem)1 StemmingSearcher (com.yahoo.prelude.querytransform.StemmingSearcher)1 Result (com.yahoo.search.Result)1 Alias (com.yahoo.search.config.IndexInfoConfig.Indexinfo.Alias)1 QueryTree (com.yahoo.search.query.QueryTree)1 Parsable (com.yahoo.search.query.parser.Parsable)1 ParserEnvironment (com.yahoo.search.query.parser.ParserEnvironment)1 AttributesConfig (com.yahoo.vespa.config.search.AttributesConfig)1 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)1