Search in sources :

Example 1 with SearchDefinition

use of com.yahoo.prelude.SearchDefinition 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 SearchDefinition

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

the class JuniperSearcherTestCase method createSearchDefinitionOne.

private SearchDefinition createSearchDefinitionOne() {
    SearchDefinition one = new SearchDefinition("one");
    Index dynteaser = new Index("dynteaser");
    dynteaser.setDynamicSummary(true);
    one.addIndex(dynteaser);
    Index bigteaser = new Index("bigteaser");
    dynteaser.setHighlightSummary(true);
    one.addIndex(bigteaser);
    Index otherteaser = new Index("otherteaser");
    otherteaser.setDynamicSummary(true);
    one.addIndex(otherteaser);
    return one;
}
Also used : Index(com.yahoo.prelude.Index) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 3 with SearchDefinition

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

the class LiteralBoostSearcherTestCase method createSearchDefinitionWithFields.

private SearchDefinition createSearchDefinitionWithFields(String name, boolean literalBoost) {
    SearchDefinition type = new SearchDefinition(name);
    Index defaultIndex = new Index("default");
    defaultIndex.setLiteralBoost(literalBoost);
    type.addIndex(defaultIndex);
    Index absoluteIndex = new Index("absolute");
    absoluteIndex.setLiteralBoost(literalBoost);
    type.addIndex(absoluteIndex);
    return type;
}
Also used : Index(com.yahoo.prelude.Index) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 4 with SearchDefinition

use of com.yahoo.prelude.SearchDefinition 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 5 with SearchDefinition

use of com.yahoo.prelude.SearchDefinition 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)

Aggregations

SearchDefinition (com.yahoo.prelude.SearchDefinition)9 IndexFacts (com.yahoo.prelude.IndexFacts)6 Index (com.yahoo.prelude.Index)5 IndexModel (com.yahoo.prelude.IndexModel)5 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 Execution (com.yahoo.search.searchchain.Execution)2 ArrayList (java.util.ArrayList)2 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)1 Query (com.yahoo.search.Query)1 QueryTree (com.yahoo.search.query.QueryTree)1 Parsable (com.yahoo.search.query.parser.Parsable)1 ParserEnvironment (com.yahoo.search.query.parser.ParserEnvironment)1 RendererRegistry (com.yahoo.search.rendering.RendererRegistry)1 YqlParser (com.yahoo.search.yql.YqlParser)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1