use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class QueryCombinatorTestCase method testMultiPart.
public void testMultiPart() {
Query q = new Query("?query=a&query.juhu=b&query.nalle=c");
Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
Set<String> items = new HashSet<>();
items.add("a");
items.add("b");
items.add("c");
e.search(q);
// OK, the problem here is we have no way of knowing whether nalle or
// juhu was added first, since we have passed through HashMap instances
// inside the implementation
AndItem root = (AndItem) q.getModel().getQueryTree().getRoot();
Iterator<?> iterator = root.getItemIterator();
while (iterator.hasNext()) {
WordItem word = (WordItem) iterator.next();
if (items.contains(word.stringValue())) {
items.remove(word.stringValue());
} else {
assertFalse("Got unexpected item in query tree: " + word.stringValue(), true);
}
}
assertEquals("Not all expected items found in query.", 0, items.size());
Set<StringPair> nastierItems = new HashSet<>();
nastierItems.add(new StringPair("", "a"));
nastierItems.add(new StringPair("juhu.22[gnuff]", "b"));
nastierItems.add(new StringPair("gnuff[8].name(\"tralala\")", "c"));
q = new Query("?query=a&query.juhu=b&defidx.juhu=juhu.22[gnuff]&query.nalle=c&defidx.nalle=gnuff[8].name(%22tralala%22)");
e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
root = (AndItem) q.getModel().getQueryTree().getRoot();
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());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class SortingDegraderTestCase method createIndexFacts.
private IndexFacts createIndexFacts() {
IndexFacts indexFacts = new IndexFacts();
Index fastSearchAttribute1 = new Index("a1");
fastSearchAttribute1.setFastSearch(true);
fastSearchAttribute1.setNumerical(true);
Index fastSearchAttribute2 = new Index("a2");
fastSearchAttribute2.setFastSearch(true);
fastSearchAttribute2.setNumerical(true);
Index nonFastSearchAttribute = new Index("nonFastSearchAttribute");
nonFastSearchAttribute.setNumerical(true);
Index stringAttribute = new Index("stringAttribute");
stringAttribute.setFastSearch(true);
indexFacts.addIndex("test", fastSearchAttribute1);
indexFacts.addIndex("test", fastSearchAttribute2);
indexFacts.addIndex("test", nonFastSearchAttribute);
indexFacts.addIndex("stringAttribute", stringAttribute);
return indexFacts;
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class RangeQueryOptimizerTestCase method parseQuery.
private Item parseQuery(String query) {
IndexFacts indexFacts = new IndexFacts();
Parser parser = ParserFactory.newInstance(Query.Type.ADVANCED, new ParserEnvironment().setIndexFacts(indexFacts).setLinguistics(linguistics));
return parser.parse(new Parsable().setQuery(query)).getRoot();
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class RangeQueryOptimizerTestCase method createIndexFacts.
private static IndexFacts createIndexFacts() {
IndexFacts indexFacts = new IndexFacts();
Index singleValue1 = new Index("s");
Index singleValue2 = new Index("t");
Index multiValue = new Index("m");
multiValue.setMultivalue(true);
indexFacts.addIndex("test", singleValue1);
indexFacts.addIndex("test", singleValue2);
indexFacts.addIndex("test", multiValue);
return indexFacts;
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class ExecutionTestCase method testContextCacheMoreSearchers.
public void testContextCacheMoreSearchers() {
IndexFacts[] contextsBefore = new IndexFacts[7];
IndexFacts[] contextsAfter = new IndexFacts[7];
List<Searcher> l = new ArrayList<>(7);
l.add(new ContextCacheSearcher(0, contextsBefore, contextsAfter));
l.add(new ContextCacheSearcher(1, contextsBefore, contextsAfter));
l.add(new ContextCacheSearcher(2, contextsBefore, contextsAfter));
l.add(new ContextCacheSearcher(3, contextsBefore, contextsAfter));
l.add(new ContextCacheSearcher(4, contextsBefore, contextsAfter));
l.add(new ContextCacheSearcher(5, contextsBefore, contextsAfter));
l.add(new ContextCacheSearcher(6, contextsBefore, contextsAfter));
Chain<Searcher> chain = new Chain<>(l);
Query query = new Query("?mutatecontext=2,4");
new Execution(chain, Execution.Context.createContextStub()).search(query);
assertSame(contextsBefore[0], contextsAfter[0]);
assertSame(contextsBefore[1], contextsAfter[1]);
assertSame(contextsBefore[2], contextsAfter[2]);
assertSame(contextsBefore[3], contextsAfter[3]);
assertSame(contextsBefore[4], contextsAfter[4]);
assertSame(contextsBefore[5], contextsAfter[5]);
assertSame(contextsBefore[6], contextsAfter[6]);
assertSame(contextsBefore[0], contextsBefore[1]);
assertNotSame(contextsBefore[1], contextsBefore[2]);
assertSame(contextsBefore[2], contextsBefore[3]);
assertNotSame(contextsBefore[3], contextsBefore[4]);
assertSame(contextsBefore[4], contextsBefore[5]);
assertSame(contextsBefore[5], contextsBefore[6]);
}
Aggregations