Search in sources :

Example 11 with IndexFacts

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());
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 12 with IndexFacts

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"));
}
Also used : Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) Test(org.junit.Test)

Example 13 with IndexFacts

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());
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 14 with IndexFacts

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());
}
Also used : Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) Test(org.junit.Test)

Example 15 with IndexFacts

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());
}
Also used : Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) Test(org.junit.Test)

Aggregations

IndexFacts (com.yahoo.prelude.IndexFacts)73 Query (com.yahoo.search.Query)41 Execution (com.yahoo.search.searchchain.Execution)34 Test (org.junit.Test)26 Index (com.yahoo.prelude.Index)22 IndexModel (com.yahoo.prelude.IndexModel)12 Result (com.yahoo.search.Result)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)7 SearchDefinition (com.yahoo.prelude.SearchDefinition)6 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)6 Chain (com.yahoo.component.chain.Chain)5 Token (com.yahoo.prelude.query.parser.Token)5 Tokenizer (com.yahoo.prelude.query.parser.Tokenizer)5 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)4 AndItem (com.yahoo.prelude.query.AndItem)4 WordItem (com.yahoo.prelude.query.WordItem)4 HashSet (java.util.HashSet)4 LinkedHashMap (java.util.LinkedHashMap)4