Search in sources :

Example 1 with Command

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

the class IndexFactsTestCase method testOverlappingAliases.

@Test
public void testOverlappingAliases() {
    IndexInfoConfig cfg = new IndexInfoConfig(new IndexInfoConfig.Builder().indexinfo(new Indexinfo.Builder().name("music2").command(new Command.Builder().indexname("btitle").command("index")).alias(new Alias.Builder().alias("title").indexname("btitle"))).indexinfo(new Indexinfo.Builder().name("music").command(new Command.Builder().indexname("title").command("index"))));
    IndexModel m = new IndexModel(cfg, (QrSearchersConfig) null);
    assertNotNull(m.getSearchDefinitions().get("music").getIndex("title"));
    assertNull(m.getSearchDefinitions().get("music").getIndex("btitle"));
    assertNotNull(m.getSearchDefinitions().get("music2").getIndex("btitle"));
    assertNotNull(m.getSearchDefinitions().get("music2").getIndex("title"));
    assertSame(m.getSearchDefinitions().get("music2").getIndex("btitle"), m.getSearchDefinitions().get("music2").getIndex("title"));
    assertNotSame(m.getSearchDefinitions().get("music").getIndex("title"), m.getSearchDefinitions().get("music2").getIndex("title"));
}
Also used : Command(com.yahoo.search.config.IndexInfoConfig.Indexinfo.Command) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Test(org.junit.Test)

Example 2 with Command

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

the class IndexFactsTestCase method testUriIndexAndRestrict.

@Test
public void testUriIndexAndRestrict() {
    IndexInfoConfig.Builder b = new IndexInfoConfig.Builder();
    IndexInfoConfig.Indexinfo.Builder b1 = new IndexInfoConfig.Indexinfo.Builder();
    b1.name("hasUri");
    IndexInfoConfig.Indexinfo.Command.Builder bb1 = new IndexInfoConfig.Indexinfo.Command.Builder();
    bb1.indexname("url");
    bb1.command("fullurl");
    b1.command(bb1);
    b.indexinfo(b1);
    IndexInfoConfig.Indexinfo.Builder b2 = new IndexInfoConfig.Indexinfo.Builder();
    b2.name("hasNotUri1");
    b.indexinfo(b2);
    IndexInfoConfig.Indexinfo.Builder b3 = new IndexInfoConfig.Indexinfo.Builder();
    b3.name("hasNotUri2");
    b.indexinfo(b3);
    IndexInfoConfig config = new IndexInfoConfig(b);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Collections.emptyMap()));
    Query query1 = new Query("?query=url:https://foo.bar");
    Query query2 = new Query("?query=url:https://foo.bar&restrict=hasUri");
    assertEquals(0, query1.getModel().getRestrict().size());
    assertEquals(1, query2.getModel().getRestrict().size());
    IndexFacts.Session session1 = indexFacts.newSession(query1.getModel().getSources(), query1.getModel().getRestrict());
    IndexFacts.Session session2 = indexFacts.newSession(query2.getModel().getSources(), query2.getModel().getRestrict());
    assertTrue(session1.getIndex("url").isUriIndex());
    assertTrue(session2.getIndex("url").isUriIndex());
    assertEquals("url:\"https foo bar\"", query1.getModel().getQueryTree().toString());
    assertEquals("url:\"https foo bar\"", query2.getModel().getQueryTree().toString());
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Command(com.yahoo.search.config.IndexInfoConfig.Indexinfo.Command) Indexinfo(com.yahoo.search.config.IndexInfoConfig.Indexinfo) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Test(org.junit.Test)

Aggregations

IndexModel (com.yahoo.prelude.IndexModel)2 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)2 Command (com.yahoo.search.config.IndexInfoConfig.Indexinfo.Command)2 Test (org.junit.Test)2 IndexFacts (com.yahoo.prelude.IndexFacts)1 Query (com.yahoo.search.Query)1 Indexinfo (com.yahoo.search.config.IndexInfoConfig.Indexinfo)1