-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Skip shards when querying constant keyword fields #96161
Changes from 15 commits
e036818
fa255a0
2f321ec
1ce1c61
6f2dd52
1262e57
ea8e00d
9f9e878
3805907
12bd7c5
73fbf4c
d80d825
d10b7e9
9318d5c
2fdeed1
f998702
0de29fe
1ce266b
88a9c0f
d963148
581eede
1acf848
65c40a4
56215c2
f77b23f
e654bed
10d76fe
7e84f10
5981421
f414b5a
4847c08
75ea39f
a0cea4e
18e4533
e45dd7c
be1292c
b5b824d
dfe9a6f
af18a36
40140cc
92d5856
59b8445
00af0d1
b27fe03
78f7ba6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 96161 | ||
summary: Skip shards when querying constant keyword fields | ||
area: "Search" | ||
type: enhancement | ||
issues: | ||
- 95541 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -692,6 +692,10 @@ public Relation isFieldWithinQuery( | |
DateMathParser dateParser, | ||
QueryRewriteContext context | ||
) throws IOException { | ||
if (reader == null) { | ||
// NOTE: in case we rewrite a query before we have a reader available | ||
return Relation.INTERSECTS; | ||
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. is this uncovering an existing bug that may be triggered by the percolator, or only caused by doing a rewrite before acquiring a searcher? 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. No bug, just doing a rewrite before we have a searcher available. |
||
} | ||
if (isIndexed() == false && pointsMetadataAvailable == false && hasDocValues()) { | ||
// we don't have a quick way to run this check on doc values, so fall back to default assuming we are within bounds | ||
return Relation.INTERSECTS; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1532,6 +1532,22 @@ public CanMatchShardResponse canMatch(ShardSearchRequest request) throws IOExcep | |
|
||
private CanMatchShardResponse canMatch(ShardSearchRequest request, boolean checkRefreshPending) throws IOException { | ||
assert request.searchType() == SearchType.QUERY_THEN_FETCH : "unexpected search type: " + request.searchType(); | ||
if (request.source() != null && (request.source().query() instanceof MatchNoneQueryBuilder) == false) { | ||
final SearchExecutionContext searchExecutionContext = new SearchExecutionContext( | ||
indicesService.indexServiceSafe(request.shardId().getIndex()) | ||
jimczi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.newSearchExecutionContext( | ||
request.shardId().getId(), | ||
request.shardRequestIndex(), | ||
null, | ||
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. Using |
||
request::nowInMillis, | ||
request.getClusterAlias(), | ||
request.getRuntimeMappings() | ||
) | ||
); | ||
if (queryStillMatchesAfterRewrite(request, searchExecutionContext) == false) { | ||
return new CanMatchShardResponse(false, null); | ||
} | ||
} | ||
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. The 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.
If we use
Good point. This should be possible even with 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.
The initial change already used 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. Right, I see this now. Yes, if we pass a null searcher then this should work. 👍 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. I had to add an additional null check in |
||
Releasable releasable = null; | ||
try { | ||
IndexService indexService; | ||
|
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.
Why was this test renamed?
I think all test cases need to have the suffix
IT
ininternalClusterTest
?