Search in sources :

Example 1 with IndexModel

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

the class JuniperSearcherTestCase method createExecution.

private Execution createExecution(Chain<Searcher> chain) {
    Map<String, List<String>> clusters = new LinkedHashMap<>();
    Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
    searchDefs.put("one", createSearchDefinitionOne());
    searchDefs.put("two", createSearchDefinitionTwo());
    SearchDefinition union = new SearchDefinition("union");
    IndexModel indexModel = new IndexModel(clusters, searchDefs, union);
    return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
Also used : Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) List(java.util.List) IndexModel(com.yahoo.prelude.IndexModel) LinkedHashMap(java.util.LinkedHashMap) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 2 with IndexModel

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

the class ClusterSearcherTestCase 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"));
    clusters.put("type1", Arrays.asList("type6"));
    Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
    searchDefs.put("type1", new SearchDefinition("type1"));
    searchDefs.put("type2", new SearchDefinition("type2"));
    searchDefs.put("type3", new SearchDefinition("type3"));
    searchDefs.put("type4", new SearchDefinition("type4"));
    searchDefs.put("type5", new SearchDefinition("type5"));
    searchDefs.put("type6", new SearchDefinition("type6"));
    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)

Example 3 with IndexModel

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

the class ParsingTester method createIndexFacts.

/**
 * Returns an unfrozen version of the IndexFacts this will use.
 * This can be used to add new indexes and passing the resulting IndexFacts to the constructor of this.
 */
public static IndexFacts createIndexFacts() {
    String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/query/parser/test/parseindexinfo.cfg";
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
    return new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel)

Example 4 with IndexModel

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

the class ValidatePredicateSearcherTestCase method doSearch.

private static Result doSearch(ValidatePredicateSearcher searcher, String yqlQuery, String command) {
    QueryTree queryTree = new YqlParser(new ParserEnvironment()).parse(new Parsable().setQuery(yqlQuery));
    Query query = new Query();
    query.getModel().getQueryTree().setRoot(queryTree.getRoot());
    TreeMap<String, List<String>> masterClusters = new TreeMap<>();
    masterClusters.put("cluster", Arrays.asList("document"));
    SearchDefinition searchDefinition = new SearchDefinition("document");
    Index index = new Index("predicate_field");
    index.addCommand(command);
    searchDefinition.addIndex(index);
    Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>();
    searchDefinitionMap.put("document", searchDefinition);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition));
    Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics());
    return new Execution(searcher, context).search(query);
}
Also used : Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) Parsable(com.yahoo.search.query.parser.Parsable) Index(com.yahoo.prelude.Index) IndexModel(com.yahoo.prelude.IndexModel) SearchDefinition(com.yahoo.prelude.SearchDefinition) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) YqlParser(com.yahoo.search.yql.YqlParser) Execution(com.yahoo.search.searchchain.Execution) QueryTree(com.yahoo.search.query.QueryTree) RendererRegistry(com.yahoo.search.rendering.RendererRegistry) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment)

Example 5 with IndexModel

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

the class SourceRefResolverTestCase method setupIndexFacts.

private static void setupIndexFacts() {
    TreeMap<String, List<String>> masterClusters = new TreeMap<>();
    masterClusters.put(cluster1, Arrays.asList("document1", "document2"));
    masterClusters.put(cluster2, Arrays.asList("document1"));
    masterClusters.put(cluster3, Arrays.asList("document3"));
    indexFacts = new IndexFacts(new IndexModel(masterClusters, null, null));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) IndexModel(com.yahoo.prelude.IndexModel)

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