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