Search in sources :

Example 46 with IndexFacts

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

the class StemmingSearcherTestCase method testEmptyIndexInfo.

@Test
public void testEmptyIndexInfo() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/emptyindexinfo.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
    Query q = new Query(QueryTestCase.httpEncode("?query=cars"));
    new Execution(new Chain<Searcher>(new StemmingSearcher(linguistics)), new Execution.Context(null, indexFacts, null, null, linguistics)).search(q);
    assertEquals("cars", q.getModel().getQueryTree().getRoot().toString());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) StemmingSearcher(com.yahoo.prelude.querytransform.StemmingSearcher) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Test(org.junit.Test)

Example 47 with IndexFacts

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

the class LowercasingTestCase method setUp.

@Before
public void setUp() throws Exception {
    IndexFacts f = new IndexFacts();
    Index bamse = new Index(BAMSE);
    Index teddy = new Index(TEDDY);
    Index defaultIndex = new Index("default");
    bamse.setLowercase(true);
    teddy.setLowercase(false);
    defaultIndex.setLowercase(true);
    f.addIndex("nalle", bamse);
    f.addIndex("nalle", teddy);
    f.addIndex("nalle", defaultIndex);
    f.freeze();
    settings = f;
    execution = new Execution(new Chain<Searcher>(new VespaLowercasingSearcher(new LowercasingConfig(new LowercasingConfig.Builder()))), Execution.Context.createContextStub(settings));
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) Index(com.yahoo.prelude.Index) Before(org.junit.Before)

Example 48 with IndexFacts

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

the class WandSearcherTestCase method buildIndexFacts.

private IndexFacts buildIndexFacts() {
    IndexFacts retval = new IndexFacts();
    retval.addIndex("test", new Index(VESPA_FIELD));
    retval.freeze();
    return retval;
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Index(com.yahoo.prelude.Index)

Example 49 with IndexFacts

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

the class QueryCombinatorTestCase method testStraightForwardSearch.

public void testStraightForwardSearch() {
    Query q = new Query("?query=a&query.juhu=b");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("AND a b", q.getModel().getQueryTree().toString());
    q = new Query("?query=a&query.juhu=b&defidx.juhu=juhu.22[gnuff]");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("AND a juhu.22[gnuff]:b", q.getModel().getQueryTree().toString());
    q = new Query("?query=a&query.juhu=");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("a", q.getModel().getQueryTree().toString());
    q = new Query("?query=a+c&query.juhu=b");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("AND a c b", q.getModel().getQueryTree().toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

Example 50 with IndexFacts

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

the class QueryCombinatorTestCase method testNoBaseQuery.

public void testNoBaseQuery() {
    Query q = new Query("?query.juhu=b");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("b", q.getModel().getQueryTree().toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

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