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));
}
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));
}
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;
}
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"));
}
Aggregations