diff options
author | Olli Virtanen <olli.virtanen@oath.com> | 2018-10-10 13:39:15 +0200 |
---|---|---|
committer | Olli Virtanen <olli.virtanen@oath.com> | 2018-10-10 13:39:15 +0200 |
commit | 81b380935d3412c29ad3f84e3c8f88361851d0d1 (patch) | |
tree | 532b09ec46fedbf7aecaf46de92d03b7a3bf4809 /container-search/src/main/java/com/yahoo/search/dispatch/SearchErrorInvoker.java | |
parent | a5c538043d29e36b3802efd8e16652540ae0d5e4 (diff) |
model.searchPath support for java dispatcher
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch/SearchErrorInvoker.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/SearchErrorInvoker.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/SearchErrorInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/SearchErrorInvoker.java new file mode 100644 index 00000000000..b716c182615 --- /dev/null +++ b/container-search/src/main/java/com/yahoo/search/dispatch/SearchErrorInvoker.java @@ -0,0 +1,43 @@ +// 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 com.yahoo.search.result.ErrorMessage; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +/** + * A search invoker that will immediately produce an error that occurred during invoker construction. + * Currently used for invalid searchpath values. + * + * @author ollivir + */ +public class SearchErrorInvoker extends SearchInvoker { + private final String message; + private Query query; + + public SearchErrorInvoker(String message) { + this.message = message; + } + + @Override + protected void sendSearchRequest(Query query, QueryPacket queryPacket) throws IOException { + this.query = query; + } + + @Override + protected List<Result> getSearchResults(CacheKey cacheKey) throws IOException { + return Arrays.asList(new Result(query, ErrorMessage.createIllegalQuery(message))); + } + + @Override + protected void release() { + // nothing to do + } + +} |