use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method testBasicCases.
@Test
public void testBasicCases() {
// First check default behavior
IndexFacts indexFacts = createIndexFacts();
Query q = newQuery("?query=a:b", indexFacts);
assertEquals("a:b", q.getModel().getQueryTree().getRoot().toString());
q = newQuery("?query=notarealindex:b", indexFacts);
assertEquals("\"notarealindex b\"", q.getModel().getQueryTree().getRoot().toString());
// Add an index to an SD which also happens to be the default
indexFacts.addIndex("one", "yetanothersynthetic");
q = newQuery("?query=yetanothersynthetic:b", indexFacts);
assertEquals("yetanothersynthetic:b", q.getModel().getQueryTree().getRoot().toString());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method testRestrictLists1.
// This is also backed by a system test on cause of complex config
@Test
public void testRestrictLists1() {
Query query = new Query();
query.getModel().getSources().add("nalle");
query.getModel().getSources().add("one");
query.getModel().getRestrict().add("two");
IndexFacts.Session indexFacts = createIndexFacts().newSession(Collections.singleton("clusterOne"), Collections.emptyList());
assertTrue(indexFacts.isIndex("a"));
assertFalse(indexFacts.isIndex("b"));
assertTrue(indexFacts.isIndex("d"));
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method testDefaultIsUnionUriIndex.
@Test
public void testDefaultIsUnionUriIndex() {
IndexFacts indexFacts = createIndexFacts();
assertTrue(indexFacts.newSession(new Query()).getIndex("d").isUriIndex());
assertFalse(indexFacts.newSession(new Query()).getIndex("a").isUriIndex());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method testRestrictLists2.
@Test
public void testRestrictLists2() {
Query query = new Query();
query.getModel().getSources().add("clusterTwo");
query.getModel().getRestrict().add("three");
IndexFacts indexFacts = createIndexFacts();
IndexFacts.Session session = indexFacts.newSession(query);
assertFalse(session.getIndex("c").isNull());
assertTrue(session.getIndex("e").isNull());
assertEquals("c", session.getCanonicName("C"));
assertTrue(session.getIndex("c").isHostIndex());
assertFalse(session.getIndex("a").isNull());
assertFalse(session.getIndex("a").isHostIndex());
assertEquals(StemMode.SHORTEST, session.getIndex("a").getStemMode());
assertFalse(session.getIndex("b").isNull());
assertFalse(session.getIndex("b").isUriIndex());
assertFalse(session.getIndex("b").isHostIndex());
assertEquals(StemMode.NONE, session.getIndex("b").getStemMode());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method testRestrictLists3.
@Test
public void testRestrictLists3() {
Query query = new Query();
query.getModel().getSources().add("clusterOne");
query.getModel().getRestrict().add("two");
IndexFacts indexFacts = createIndexFacts();
IndexFacts.Session session = indexFacts.newSession(query);
assertTrue(session.getIndex("a").isNull());
assertFalse(session.getIndex("d").isNull());
assertTrue(session.getIndex("d").isUriIndex());
assertTrue(session.getIndex("e").isExact());
}
Aggregations