use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class LegacyCombinator method search.
@Override
public Result search(Query query, Execution execution) {
Set<QueryPart> pieces;
Set<String> usedSources;
IndexFacts indexFacts = execution.context().getIndexFacts();
try {
pieces = findQuerySnippets(query.properties());
} catch (IllegalArgumentException e) {
query.errors().add(ErrorMessage.createInvalidQueryParameter("LegacyCombinator got invalid parameters: " + e.getMessage()));
return execution.search(query);
}
if (pieces.size() == 0) {
return execution.search(query);
}
IndexFacts.Session session = indexFacts.newSession(query);
Language language = query.getModel().getParsingLanguage();
addAndItems(language, query, pieces, session, execution.context());
addRankItems(language, query, pieces, session, execution.context());
try {
addNotItems(language, query, pieces, session, execution.context());
} catch (IllegalArgumentException e) {
query.errors().add(ErrorMessage.createInvalidQueryParameter("LegacyCombinator found only excluding terms, no including."));
return execution.search(query);
}
query.trace("Adding extra query parts.", true, 2);
return execution.search(query);
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class NGramSearcher method search.
@Override
public Result search(Query query, Execution execution) {
IndexFacts indexFacts = execution.context().getIndexFacts();
// shortcut
if (!indexFacts.hasNGramIndices())
return execution.search(query);
IndexFacts.Session session = indexFacts.newSession(query);
boolean rewritten = rewriteToNGramMatching(query.getModel().getQueryTree().getRoot(), 0, session, query);
if (rewritten)
query.trace("Rewritten to n-gram matching", true, 2);
Result result = execution.search(query);
recombineNGrams(result.hits().deepIterator(), session);
return result;
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class NGramSearcher method fill.
@Override
public void fill(Result result, String summaryClass, Execution execution) {
execution.fill(result, summaryClass);
IndexFacts indexFacts = execution.context().getIndexFacts();
if (indexFacts.hasNGramIndices())
recombineNGrams(result.hits().deepIterator(), indexFacts.newSession(result.getQuery()));
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class ParsingTester method createIndexFacts.
/**
* Returns an unfrozen version of the IndexFacts this will use.
* This can be used to add new indexes and passing the resulting IndexFacts to the constructor of this.
*/
public static IndexFacts createIndexFacts() {
String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/query/parser/test/parseindexinfo.cfg";
ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
return new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class QueryCombinatorTestCase method testDefaultIndexWithoutQuery.
public void testDefaultIndexWithoutQuery() {
Query q = new Query("?defidx.juhu=b");
Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("NULL", q.getModel().getQueryTree().toString());
q = new Query("?query=a&defidx.juhu=b");
e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
e.search(q);
assertEquals("a", q.getModel().getQueryTree().toString());
}
Aggregations