-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix failure for validate API on a terms query #29483
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b22eeb8
WIP commit to try calling rewrite on coordinating node during Transpo…
8127f2d
Use re-written query instead of using the original query
c291ea0
Merge branch 'master' into terms-query-validate-bug
f94a48a
fix incorrect/unused imports and wildcarding
3e4b77c
add error handling for cases where an exception is thrown
392431e
Merge branch 'master' into terms-query-validate-bug
f218da2
correct exception handling such that integration tests pass successfully
4925ba8
fix additional case covered by IndicesOptionsIntegrationIT.
454ab2b
Merge branch 'master' into terms-query-validate-bug
3849ae6
add integration test case that verifies queries are now valid
ddc9f42
Merge branch 'master' into terms-query-validate-bug
e0003d0
Merge branch 'master' into terms-query-validate-bug
39330c9
Merge branch 'master' into terms-query-validate-bug
226da40
add optional value for index
6d5eeff
address review comments: catch superclass of XContentParseException
f5dd57d
Merge branch 'master' into terms-query-validate-bug
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,11 @@ | |
import org.apache.lucene.search.MatchNoDocsQuery; | ||
import org.apache.lucene.search.Query; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.OriginalIndices; | ||
import org.elasticsearch.action.search.SearchResponse; | ||
import org.elasticsearch.action.search.SearchShardIterator; | ||
import org.elasticsearch.action.search.SearchTask; | ||
import org.elasticsearch.action.search.TransportSearchAction; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.DefaultShardOperationFailedException; | ||
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException; | ||
|
@@ -30,6 +35,7 @@ | |
import org.elasticsearch.cluster.block.ClusterBlockException; | ||
import org.elasticsearch.cluster.block.ClusterBlockLevel; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.routing.GroupShardsIterator; | ||
import org.elasticsearch.cluster.routing.ShardRouting; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
|
@@ -39,21 +45,24 @@ | |
import org.elasticsearch.common.lease.Releasables; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.index.query.ParsedQuery; | ||
import org.elasticsearch.index.query.QueryBuilders; | ||
import org.elasticsearch.index.query.QueryShardException; | ||
import org.elasticsearch.index.query.Rewriteable; | ||
import org.elasticsearch.search.SearchService; | ||
import org.elasticsearch.search.builder.SearchSourceBuilder; | ||
import org.elasticsearch.search.internal.AliasFilter; | ||
import org.elasticsearch.search.internal.SearchContext; | ||
import org.elasticsearch.search.internal.ShardSearchLocalRequest; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.RemoteClusterAware; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fail |
||
import java.util.concurrent.atomic.AtomicReferenceArray; | ||
import java.util.function.BiFunction; | ||
import java.util.function.LongSupplier; | ||
|
||
public class TransportValidateQueryAction extends TransportBroadcastAction<ValidateQueryRequest, ValidateQueryResponse, ShardValidateQueryRequest, ShardValidateQueryResponse> { | ||
|
||
|
@@ -71,7 +80,17 @@ public TransportValidateQueryAction(Settings settings, ThreadPool threadPool, Cl | |
@Override | ||
protected void doExecute(Task task, ValidateQueryRequest request, ActionListener<ValidateQueryResponse> listener) { | ||
request.nowInMillis = System.currentTimeMillis(); | ||
super.doExecute(task, request, listener); | ||
LongSupplier timeProvider = () -> request.nowInMillis; | ||
ActionListener<org.elasticsearch.index.query.QueryBuilder> rewriteListener = ActionListener.wrap(rewrittenQuery -> { | ||
request.query(rewrittenQuery); | ||
super.doExecute(task, request, listener); | ||
}, listener::onFailure); | ||
if (request.query() == null) { | ||
rewriteListener.onResponse(request.query()); | ||
} else { | ||
Rewriteable.rewriteAndFetch(request.query(), searchService.getRewriteContext(timeProvider), | ||
rewriteListener); | ||
} | ||
} | ||
|
||
@Override | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a lot of unnecessary imports here.