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"));
}
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());
}
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;
}
Aggregations