use of com.yahoo.search.Query in project vespa by vespa-engine.
the class ApplicationTest method container_and_referenced_content.
/**
* Tests that an application with search chains referencing a content cluster can be constructed.
*/
@Test
public void container_and_referenced_content() throws Exception {
try (Application application = Application.fromApplicationPackage(new File("src/test/app-packages/withcontent"), Networking.disable)) {
Result result = application.getJDisc("default").search().process(new ComponentSpecification("default"), new Query("?query=substring:foobar&tracelevel=3"));
assertEquals("AND substring:fo substring:oo substring:ob substring:ba substring:ar", result.hits().get("hasQuery").getQuery().getModel().getQueryTree().toString());
}
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class ApplicationTest method search_default.
@Test
public void search_default() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container().searcher(MockSearcher.class))))) {
Result result = app.search(new Query("?query=foo"));
assertEquals(1, result.hits().size());
}
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class ApplicationTest method search.
@Test
public void search() throws Exception {
try (ApplicationFacade app = new ApplicationFacade(Application.fromBuilder(new Application.Builder().container("default", new Application.Builder.Container().searcher("foo", MockSearcher.class))))) {
Result result = app.search("foo", new Query("?query=foo"));
assertEquals(1, result.hits().size());
}
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class ClusterSearcher method searchMultipleDocumentTypes.
private Result searchMultipleDocumentTypes(Searcher searcher, Query query, Execution execution) {
Set<String> docTypes = resolveDocumentTypes(query, execution.context().getIndexFacts());
Result invalidRankProfile = checkValidRankProfiles(query, docTypes);
if (invalidRankProfile != null) {
return invalidRankProfile;
}
List<Query> queries = createQueries(query, docTypes);
if (queries.size() == 1) {
return searcher.search(queries.get(0), execution);
} else {
Result mergedResult = new Result(query.clone());
for (Query q : queries) {
Result result = searcher.search(q, execution);
mergedResult.mergeWith(result);
mergedResult.hits().addAll(result.hits().asUnorderedHits());
}
// Should we trim the merged result?
if (query.getOffset() > 0 || query.getHits() < mergedResult.hits().size()) {
if (mergedResult.getHitOrderer() != null) {
// Make sure we have the necessary data for sorting
searcher.fill(mergedResult, Execution.ATTRIBUTEPREFETCH, execution);
}
mergedResult.hits().trim(query.getOffset(), query.getHits());
}
return mergedResult;
}
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class PacketQueryTracer method addTrace.
private void addTrace(FS4Channel channel, BasicPacket packet, ByteBuffer serializedForm) {
Query query = channel.getQuery();
if (query != null && query.getTraceLevel() >= traceLevel) {
StringBuilder traceString = new StringBuilder();
traceString.append(packet.getClass().getSimpleName()).append(": ");
hexDump(serializedForm, traceString);
final boolean includeQuery = true;
query.trace(traceString.toString(), includeQuery, traceLevel);
}
}
Aggregations