Search in sources :

Example 6 with SearchDefinition

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

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

Example 8 with SearchDefinition

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

the class NormalizingSearcherTestCase method createSearchDefinitionWithFields.

private SearchDefinition createSearchDefinitionWithFields(String name, boolean normalize) {
    SearchDefinition type = new SearchDefinition(name);
    Index defaultIndex = new Index("default");
    defaultIndex.setNormalize(normalize);
    type.addIndex(defaultIndex);
    Index absoluteIndex = new Index("absolute");
    absoluteIndex.setNormalize(normalize);
    type.addIndex(absoluteIndex);
    Index normalizercheckIndex = new Index("normalizercheck");
    normalizercheckIndex.setNormalize(normalize);
    type.addIndex(normalizercheckIndex);
    Index attributeIndex = new Index("attribute");
    attributeIndex.setAttribute(true);
    type.addIndex(attributeIndex);
    return type;
}
Also used : Index(com.yahoo.prelude.Index) SearchDefinition(com.yahoo.prelude.SearchDefinition)

Example 9 with SearchDefinition

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

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