summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorOlli Virtanen <olli.virtanen@oath.com>2018-10-29 16:07:16 +0100
committerOlli Virtanen <olli.virtanen@oath.com>2018-10-29 16:07:16 +0100
commit403aa78db71119e50e0280c9d15dff88f75e502d (patch)
treeb6b33edf60329b5e34e824e97772c2a2f4c37742 /container-search
parent00326a0327f802026f6737e31c0078842d976ffa (diff)
Hitcount estimate support for java dispatcher
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
index 235e7af09d2..286eee004c5 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java
@@ -88,21 +88,26 @@ public class Dispatcher extends AbstractComponent {
public Optional<SearchInvoker> getSearchInvoker(Query query, FS4InvokerFactory fs4InvokerFactory) {
if (query.properties().getBoolean(dispatchInternal, false)) {
- String searchPath = query.getModel().getSearchPath();
- if (searchPath != null) {
- Optional<SearchInvoker> invoker = getSearchPathInvoker(query, searchPath, fs4InvokerFactory::getSearchInvoker);
- if (invoker.isPresent()) {
- return invoker;
- }
+ Optional<SearchInvoker> invoker = getSearchPathInvoker(query, fs4InvokerFactory::getSearchInvoker);
+
+ if(! invoker.isPresent()) {
+ invoker = getInternalInvoker(query, fs4InvokerFactory::getSearchInvoker);
+ }
+ if(invoker.isPresent() && query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE)) {
+ query.setHits(0);
+ query.setOffset(0);
}
- Optional<SearchInvoker> invoker = getInternalInvoker(query, fs4InvokerFactory::getSearchInvoker);
return invoker;
}
return Optional.empty();
}
// build invoker based on searchpath
- private Optional<SearchInvoker> getSearchPathInvoker(Query query, String searchPath, SearchInvokerSupplier invokerFactory) {
+ private Optional<SearchInvoker> getSearchPathInvoker(Query query, SearchInvokerSupplier invokerFactory) {
+ String searchPath = query.getModel().getSearchPath();
+ if(searchPath == null) {
+ return Optional.empty();
+ }
try {
List<SearchCluster.Node> nodes = SearchPath.selectNodes(searchPath, searchCluster);
if (nodes.isEmpty()) {