Search in sources :

Example 6 with IndexInfoConfig

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

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

Example 8 with IndexInfoConfig

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

the class IndexFactsTestCase method createIndexFacts.

private IndexFacts createIndexFacts() {
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(INDEXFACTS_TESTING);
    List<String> clusterOne = new ArrayList<>();
    List<String> clusterTwo = new ArrayList<>();
    clusterOne.addAll(Arrays.asList("one", "two"));
    clusterTwo.addAll(Arrays.asList("one", "three"));
    Map<String, List<String>> clusters = new HashMap<>();
    clusters.put("clusterOne", clusterOne);
    clusters.put("clusterTwo", clusterTwo);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(config, clusters));
    return indexFacts;
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) HashMap(java.util.HashMap) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel)

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