Search in sources :

Example 36 with Index

use of com.yahoo.prelude.Index in project vespa by vespa-engine.

the class IndexFactsTestCase method testDefaultPosition.

@Test
public void testDefaultPosition() {
    Index a = new Index("a");
    assertFalse(a.isDefaultPosition());
    a.addCommand("any");
    assertFalse(a.isDefaultPosition());
    a.addCommand("default-position");
    assertTrue(a.isDefaultPosition());
    SearchDefinition sd = new SearchDefinition("sd");
    sd.addCommand("b", "any");
    assertNull(sd.getDefaultPosition());
    sd.addCommand("c", "default-position");
    assertTrue(sd.getDefaultPosition().equals("c"));
    SearchDefinition sd2 = new SearchDefinition("sd");
    sd2.addIndex(new Index("b").addCommand("any"));
    assertNull(sd2.getDefaultPosition());
    sd2.addIndex(a);
    assertTrue(sd2.getDefaultPosition().equals("a"));
    Map<String, SearchDefinition> m = new TreeMap<>();
    m.put(sd.getName(), sd);
    IndexFacts indexFacts = createIndexFacts();
    indexFacts.setSearchDefinitions(m, sd2);
    assertTrue(indexFacts.getDefaultPosition(null).equals("a"));
    assertTrue(indexFacts.getDefaultPosition("sd").equals("c"));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Index(com.yahoo.prelude.Index) TreeMap(java.util.TreeMap) SearchDefinition(com.yahoo.prelude.SearchDefinition) Test(org.junit.Test)

Aggregations

Index (com.yahoo.prelude.Index)36 IndexFacts (com.yahoo.prelude.IndexFacts)23 Test (org.junit.Test)13 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)7 Query (com.yahoo.search.Query)6 SearchDefinition (com.yahoo.prelude.SearchDefinition)5 Token (com.yahoo.prelude.query.parser.Token)5 Tokenizer (com.yahoo.prelude.query.parser.Tokenizer)5 Execution (com.yahoo.search.searchchain.Execution)4 JSONString (com.yahoo.prelude.hitfield.JSONString)2 XMLString (com.yahoo.prelude.hitfield.XMLString)2 CompositeItem (com.yahoo.prelude.query.CompositeItem)2 Hit (com.yahoo.search.result.Hit)2 List (java.util.List)2 Before (org.junit.Before)2 Chain (com.yahoo.component.chain.Chain)1 Language (com.yahoo.language.Language)1 StemMode (com.yahoo.language.process.StemMode)1 IndexModel (com.yahoo.prelude.IndexModel)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1