Search in sources :

Example 11 with IndexModel

use of com.yahoo.prelude.IndexModel 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 12 with IndexModel

use of com.yahoo.prelude.IndexModel 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 13 with IndexModel

use of com.yahoo.prelude.IndexModel 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

IndexModel (com.yahoo.prelude.IndexModel)13 IndexFacts (com.yahoo.prelude.IndexFacts)12 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)7 List (java.util.List)6 SearchDefinition (com.yahoo.prelude.SearchDefinition)5 Test (org.junit.Test)5 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)4 Query (com.yahoo.search.Query)4 Execution (com.yahoo.search.searchchain.Execution)4 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)3 Indexinfo (com.yahoo.search.config.IndexInfoConfig.Indexinfo)2 Command (com.yahoo.search.config.IndexInfoConfig.Indexinfo.Command)2 QueryTree (com.yahoo.search.query.QueryTree)2 Parsable (com.yahoo.search.query.parser.Parsable)2 ParserEnvironment (com.yahoo.search.query.parser.ParserEnvironment)2 Chain (com.yahoo.component.chain.Chain)1 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)1 Index (com.yahoo.prelude.Index)1