Search in sources :

Example 6 with IndexModel

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

the class LiteralBoostSearcherTestCase method createIndexFacts.

private IndexFacts createIndexFacts() {
    Map<String, List<String>> clusters = new LinkedHashMap<>();
    clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
    clusters.put("cluster2", Arrays.asList("type4", "type5"));
    Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
    searchDefs.put("type1", createSearchDefinitionWithFields("type1", true));
    searchDefs.put("type2", createSearchDefinitionWithFields("type2", false));
    searchDefs.put("type3", new SearchDefinition("type3"));
    searchDefs.put("type3", new SearchDefinition("type3"));
    searchDefs.put("type4", new SearchDefinition("type4"));
    searchDefs.put("type5", new SearchDefinition("type5"));
    SearchDefinition union = new SearchDefinition("union");
    return new IndexFacts(new IndexModel(clusters, searchDefs, union));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) List(java.util.List) IndexModel(com.yahoo.prelude.IndexModel) LinkedHashMap(java.util.LinkedHashMap) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 7 with IndexModel

use of com.yahoo.prelude.IndexModel 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 8 with IndexModel

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

the class YqlParserTestCase method testFieldAliases.

@Test
public void testFieldAliases() {
    IndexInfoConfig modelConfig = new IndexInfoConfig(new IndexInfoConfig.Builder().indexinfo(new Indexinfo.Builder().name("music").command(new Command.Builder().indexname("title").command("index")).alias(new Alias.Builder().alias("song").indexname("title"))));
    IndexModel model = new IndexModel(modelConfig, (QrSearchersConfig) null);
    IndexFacts indexFacts = new IndexFacts(model);
    ParserEnvironment parserEnvironment = new ParserEnvironment().setIndexFacts(indexFacts);
    YqlParser configuredParser = new YqlParser(parserEnvironment);
    QueryTree x = configuredParser.parse(new Parsable().setQuery("select * from sources * where title contains \"a\" and song contains \"b\";"));
    List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
    assertEquals(2, terms.size());
    for (IndexedItem term : terms) {
        assertEquals("title", term.getIndexName());
    }
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) IndexedItem(com.yahoo.prelude.query.IndexedItem) Parsable(com.yahoo.search.query.parser.Parsable) IndexModel(com.yahoo.prelude.IndexModel) Alias(com.yahoo.search.config.IndexInfoConfig.Indexinfo.Alias) Indexinfo(com.yahoo.search.config.IndexInfoConfig.Indexinfo) QueryTree(com.yahoo.search.query.QueryTree) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment) Test(org.junit.Test)

Example 9 with IndexModel

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

the class IndexCombinatorTestCase method testMixedIndicesAndAttributes.

@Test
public void testMixedIndicesAndAttributes() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/indexcombinator.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    IndexFacts facts = new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
    Result r = new Execution(transformer, Execution.Context.createContextStub(facts)).search(new Query(QueryTestCase.httpEncode("?query=\"a b\"")));
    assertEquals("OR default:\"a b\" attribute1:a b attribute2:a b", r.getQuery().getModel().getQueryTree().getRoot().toString());
    r = new Execution(transformer, Execution.Context.createContextStub(facts)).search(new Query(QueryTestCase.httpEncode("?query=\"a b\" \"c d\"")));
    assertEquals("OR (AND default:\"a b\" default:\"c d\")" + " (AND default:\"a b\" attribute1:c d)" + " (AND default:\"a b\" attribute2:c d)" + " (AND attribute1:a b default:\"c d\")" + " (AND attribute1:a b attribute1:c d)" + " (AND attribute1:a b attribute2:c d)" + " (AND attribute2:a b default:\"c d\")" + " (AND attribute2:a b attribute1:c d)" + " (AND attribute2:a b attribute2:c d)", r.getQuery().getModel().getQueryTree().getRoot().toString());
}
Also used : 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) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 10 with IndexModel

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

the class NormalizingSearcherTestCase method createIndexFacts.

private IndexFacts createIndexFacts() {
    Map<String, List<String>> clusters = new LinkedHashMap<>();
    clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
    clusters.put("cluster2", Arrays.asList("type4", "type5"));
    Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
    searchDefs.put("type1", createSearchDefinitionWithFields("type1", true));
    searchDefs.put("type2", createSearchDefinitionWithFields("type2", false));
    searchDefs.put("type3", new SearchDefinition("type3"));
    searchDefs.put("type3", new SearchDefinition("type3"));
    searchDefs.put("type4", new SearchDefinition("type4"));
    searchDefs.put("type5", new SearchDefinition("type5"));
    SearchDefinition union = new SearchDefinition("union");
    return new IndexFacts(new IndexModel(clusters, searchDefs, union));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) ArrayList(java.util.ArrayList) List(java.util.List) IndexModel(com.yahoo.prelude.IndexModel) LinkedHashMap(java.util.LinkedHashMap) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Aggregations

IndexModel (com.yahoo.prelude.IndexModel)13 IndexFacts (com.yahoo.prelude.IndexFacts)12 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)7 List (java.util.List)6 SearchDefinition (com.yahoo.prelude.SearchDefinition)5 Test (org.junit.Test)5 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)4 Query (com.yahoo.search.Query)4 Execution (com.yahoo.search.searchchain.Execution)4 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)3 Indexinfo (com.yahoo.search.config.IndexInfoConfig.Indexinfo)2 Command (com.yahoo.search.config.IndexInfoConfig.Indexinfo.Command)2 QueryTree (com.yahoo.search.query.QueryTree)2 Parsable (com.yahoo.search.query.parser.Parsable)2 ParserEnvironment (com.yahoo.search.query.parser.ParserEnvironment)2 Chain (com.yahoo.component.chain.Chain)1 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)1 Index (com.yahoo.prelude.Index)1