use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method createIndexFacts.
private IndexFacts createIndexFacts() {
ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
IndexInfoConfig config = getter.getConfig(INDEXFACTS_TESTING);
List<String> clusterOne = new ArrayList<>();
List<String> clusterTwo = new ArrayList<>();
clusterOne.addAll(Arrays.asList("one", "two"));
clusterTwo.addAll(Arrays.asList("one", "three"));
Map<String, List<String>> clusters = new HashMap<>();
clusters.put("clusterOne", clusterOne);
clusters.put("clusterTwo", clusterTwo);
IndexFacts indexFacts = new IndexFacts(new IndexModel(config, clusters));
return indexFacts;
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class LegacyCombinatorTestCase method testIncompatibleNewAndOldQuery.
public void testIncompatibleNewAndOldQuery() {
Query q = new Query("?query.juhu=b&defidx.juhu=a&query.juhu.defidx=c");
Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("NULL", q.getModel().getQueryTree().toString());
assertTrue("No expected error found.", q.errors().size() > 0);
assertEquals("Did not get invalid query parameter error as expected.", Error.INVALID_QUERY_PARAMETER.code, q.errors().get(0).getCode());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class LegacyCombinatorTestCase method testStraightForwardSearch.
public void testStraightForwardSearch() {
Query q = new Query("?query=a&query.juhu=b");
Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("AND a b", q.getModel().getQueryTree().toString());
q = new Query("?query=a&query.juhu=b&defidx.juhu=juhu.22[gnuff]");
e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("AND a juhu.22[gnuff]:b", q.getModel().getQueryTree().toString());
q = new Query("?query=a&query.juhu=");
e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("a", q.getModel().getQueryTree().toString());
q = new Query("?query=a+c&query.juhu=b");
e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("AND a c b", q.getModel().getQueryTree().toString());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class LegacyCombinatorTestCase method testRankAndNot.
public void testRankAndNot() {
Query q = new Query("?query.yahoo=2&query.yahoo.defidx=1&query.yahoo.operator=not&query.juhu=b&query.juhu.defidx=nalle&query.juhu.operator=rank");
Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("+nalle:b -1:2", q.getModel().getQueryTree().toString());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class LegacyCombinatorTestCase method testNewAndOld.
public void testNewAndOld() {
Query q = new Query("?query.juhu=b&defidx.juhu=nalle&query.bamse=z&query.bamse.defidx=y");
Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
Set<StringPair> nastierItems = new HashSet<>();
nastierItems.add(new StringPair("nalle", "b"));
nastierItems.add(new StringPair("y", "z"));
e.search(q);
AndItem root = (AndItem) q.getModel().getQueryTree().getRoot();
Iterator<?> iterator = root.getItemIterator();
while (iterator.hasNext()) {
WordItem word = (WordItem) iterator.next();
StringPair asPair = new StringPair(word.getIndexName(), word.stringValue());
if (nastierItems.contains(asPair)) {
nastierItems.remove(asPair);
} else {
assertFalse("Got unexpected item in query tree: (" + word.getIndexName() + ", " + word.stringValue() + ")", true);
}
}
assertEquals("Not all expected items found in query.", 0, nastierItems.size());
}
Aggregations