forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a cluster setting to disallow slow queries
Add a new cluster setting `search.disallow_slow_queries` which by default is `false`. If set to `true` then certain queries (prefix, fuzzy, regexp and wildcard) that have usually slow performance cannot be executed and an exception is thrown. Closes: elastic#29050
- Loading branch information
Showing
31 changed files
with
496 additions
and
56 deletions.
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
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
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
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
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
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
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
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
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
213 changes: 213 additions & 0 deletions
213
rest-api-spec/src/main/resources/rest-api-spec/test/search/320_disallow_queries.yml
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 |
---|---|---|
@@ -0,0 +1,213 @@ | ||
--- | ||
setup: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "implemented in 8.0.0" | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
properties: | ||
text: | ||
type: text | ||
analyzer: standard | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{"index": {"_index": "test", "_id": "1"}}' | ||
- '{"text" : "Some like it hot, some like it cold"}' | ||
- '{"index": {"_index": "test", "_id": "2"}}' | ||
- '{"text" : "Its cold outside, theres no kind of atmosphere"}' | ||
- '{"index": {"_index": "test", "_id": "3"}}' | ||
- '{"text" : "Baby its cold there outside"}' | ||
- '{"index": {"_index": "test", "_id": "4"}}' | ||
- '{"text" : "Outside it is cold and wet"}' | ||
|
||
--- | ||
teardown: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "implemented in 8.0.0" | ||
|
||
- do: | ||
cluster.put_settings: | ||
body: | ||
transient: | ||
search.disallow_slow_queries: null | ||
|
||
--- | ||
"Test disallow slow queries": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "implemented in 8.0.0" | ||
|
||
### Check for initial setting = null -> false | ||
- do: | ||
cluster.get_settings: | ||
flat_settings: true | ||
|
||
- match: {search.disallow_slow_queries: null} | ||
|
||
### Prefix | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
prefix: | ||
text: | ||
value: out | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
### Fuzzy | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
fuzzy: | ||
text: | ||
value: outwide | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
|
||
### Regexp | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
regexp: | ||
text: | ||
value: .*ou.*id.* | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
### Wildcard | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
wildcard: | ||
text: | ||
value: out?ide | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
### Update setting to true | ||
- do: | ||
cluster.put_settings: | ||
body: | ||
transient: | ||
search.disallow_slow_queries: "true" | ||
flat_settings: true | ||
|
||
- match: {transient: {search.disallow_slow_queries: "true"}} | ||
|
||
### Prefix | ||
- do: | ||
catch: /prefix queries cannot be executed when \'search.disallow_slow_queries\' is set to true/ | ||
search: | ||
index: test | ||
body: | ||
query: | ||
prefix: | ||
text: | ||
value: out | ||
|
||
### Fuzzy | ||
- do: | ||
catch: /fuzzy queries cannot be executed when \'search.disallow_slow_queries\' is set to true/ | ||
search: | ||
index: test | ||
body: | ||
query: | ||
fuzzy: | ||
text: | ||
value: outwide | ||
|
||
### Regexp | ||
- do: | ||
catch: /regexp queries cannot be executed when \'search.disallow_slow_queries\' is set to true/ | ||
search: | ||
index: test | ||
body: | ||
query: | ||
regexp: | ||
text: | ||
value: .*ou.*id.* | ||
|
||
### Wildcard | ||
- do: | ||
catch: /wildcard queries cannot be executed when \'search.disallow_slow_queries\' is set to true/ | ||
search: | ||
index: test | ||
body: | ||
query: | ||
wildcard: | ||
text: | ||
value: out?ide | ||
|
||
### Revert setting to false | ||
- do: | ||
cluster.put_settings: | ||
body: | ||
transient: | ||
search.disallow_slow_queries: "false" | ||
flat_settings: true | ||
|
||
- match: {transient: {search.disallow_slow_queries: "false"}} | ||
|
||
### Prefix | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
prefix: | ||
text: | ||
value: out | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
### Fuzzy | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
fuzzy: | ||
text: | ||
value: outwide | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
### Regexp | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
regexp: | ||
text: | ||
value: .*ou.*id.* | ||
|
||
- match: { hits.total.value: 3 } | ||
|
||
### Wildcard | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
wildcard: | ||
text: | ||
value: out?ide | ||
|
||
- match: { hits.total.value: 3 } |
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
Oops, something went wrong.