aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java
diff options
context:
space:
mode:
authorOlli Virtanen <olli.virtanen@oath.com>2018-10-01 10:50:08 +0200
committerOlli Virtanen <olli.virtanen@oath.com>2018-10-01 10:50:08 +0200
commit9caaebede97014fd3427a63a765932c9fbede1a8 (patch)
tree4288335cb2f4a5277cc7ddc3ad672e6536993668 /container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java
parent157c8b77cfe432d0476f91eb87780e6b1fcd499f (diff)
CloseableChannel split to search and fill inokers
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java
new file mode 100644
index 00000000000..53e09823f32
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/SearchInvoker.java
@@ -0,0 +1,32 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.search.dispatch;
+
+import com.yahoo.fs4.QueryPacket;
+import com.yahoo.prelude.fastsearch.CacheKey;
+import com.yahoo.search.Query;
+import com.yahoo.search.Result;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * SearchInvoker encapsulates an allocated connection for running a single search query.
+ * The invocation object can be stateful and should not be reused.
+ *
+ * @author ollivir
+ */
+public abstract class SearchInvoker extends CloseableInvoker {
+ /**
+ * Retrieve the hits for the given {@link Query}. The invoker may return more than one result, in which case the caller is responsible
+ * for merging the results. If multiple results are returned and the search query had a hit offset other than zero, that offset is
+ * set to zero and the number of requested hits is adjusted accordingly.
+ */
+ public List<Result> search(Query query, QueryPacket queryPacket, CacheKey cacheKey) throws IOException {
+ sendSearchRequest(query, queryPacket);
+ return getSearchResults(cacheKey);
+ }
+
+ protected abstract void sendSearchRequest(Query query, QueryPacket queryPacket) throws IOException;
+
+ protected abstract List<Result> getSearchResults(CacheKey cacheKey) throws IOException;
+}