Search in sources :

Example 1 with Alias

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

Aggregations

IndexFacts (com.yahoo.prelude.IndexFacts)1 IndexModel (com.yahoo.prelude.IndexModel)1 IndexedItem (com.yahoo.prelude.query.IndexedItem)1 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)1 Indexinfo (com.yahoo.search.config.IndexInfoConfig.Indexinfo)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 Test (org.junit.Test)1