-
Notifications
You must be signed in to change notification settings - Fork 491
Support ignore_unavailable query param #5971
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,6 +366,7 @@ fn simplify_search_request_for_scroll_api(req: &SearchRequest) -> crate::Result< | |
| // request is simplified after initial query, and we cache the hit count, so we don't need | ||
| // to recompute it afterward. | ||
| count_hits: quickwit_proto::search::CountHits::Underestimate as i32, | ||
| ignore_missing_indexes: req.ignore_missing_indexes, | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -1156,7 +1157,12 @@ async fn plan_splits_for_root_search( | |
| .deserialize_indexes_metadata() | ||
| .await?; | ||
|
|
||
| check_all_index_metadata_found(&indexes_metadata[..], &search_request.index_id_patterns[..])?; | ||
| if !search_request.ignore_missing_indexes { | ||
| check_all_index_metadata_found( | ||
| &indexes_metadata[..], | ||
| &search_request.index_id_patterns[..], | ||
| )?; | ||
| } | ||
|
|
||
| if indexes_metadata.is_empty() { | ||
| return Ok((Vec::new(), HashMap::default())); | ||
|
|
@@ -1243,7 +1249,12 @@ pub async fn search_plan( | |
| .deserialize_indexes_metadata() | ||
| .await?; | ||
|
|
||
| check_all_index_metadata_found(&indexes_metadata[..], &search_request.index_id_patterns[..])?; | ||
| if !search_request.ignore_missing_indexes { | ||
| check_all_index_metadata_found( | ||
| &indexes_metadata[..], | ||
| &search_request.index_id_patterns[..], | ||
| )?; | ||
| } | ||
|
Member
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. Please add tests in the file. Tedious but doable :) You can also push the |
||
| if indexes_metadata.is_empty() { | ||
| return Ok(SearchPlanResponse { | ||
| result: serde_json::to_string(&SearchPlanResponseRest { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ use crate::simple_list::{from_simple_list, to_simple_list}; | |
|
|
||
| // Multi search doc: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html | ||
|
|
||
| #[serde_as] | ||
| #[serde_with::skip_serializing_none] | ||
| #[derive(Default, Debug, Serialize, Deserialize)] | ||
| #[serde(deny_unknown_fields)] | ||
|
|
@@ -50,6 +51,9 @@ pub struct MultiSearchQueryParams { | |
| pub ignore_throttled: Option<bool>, | ||
| #[serde(default)] | ||
| pub ignore_unavailable: Option<bool>, | ||
| #[serde_as(deserialize_as = "OneOrMany<_, PreferMany>")] | ||
| #[serde(default)] | ||
| pub index: Vec<String>, | ||
|
Member
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. Can you add a comment such as |
||
| #[serde(default)] | ||
| pub max_concurrent_searches: Option<u64>, | ||
| #[serde(default)] | ||
|
|
@@ -100,6 +104,26 @@ pub struct MultiSearchHeader { | |
| pub routing: Option<Vec<String>>, | ||
| } | ||
|
|
||
| impl MultiSearchHeader { | ||
| pub fn apply_query_param_defaults(&mut self, defaults: &MultiSearchQueryParams) { | ||
| if self.allow_no_indices.is_none() { | ||
| self.allow_no_indices = defaults.allow_no_indices; | ||
| } | ||
| if self.expand_wildcards.is_none() { | ||
| self.expand_wildcards = defaults.expand_wildcards.clone(); | ||
| } | ||
| if self.ignore_unavailable.is_none() { | ||
| self.ignore_unavailable = defaults.ignore_unavailable; | ||
| } | ||
| if self.index.is_empty() { | ||
| self.index = defaults.index.clone(); | ||
| } | ||
| if self.routing.is_none() { | ||
| self.routing = defaults.routing.clone(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Serialize)] | ||
| pub struct MultiSearchResponse { | ||
| pub responses: Vec<MultiSearchSingleResponse>, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,3 +104,25 @@ expected: | |
| $expect: "len(val) == 1" # Contains only 'actor' | ||
| actor: | ||
| id: 5688 | ||
| --- | ||
| # test missing index | ||
| endpoint: "_msearch" | ||
| method: POST | ||
| ndjson: | ||
| - {"index":"idontexist"} | ||
| - {"query" : {"match" : { "type": "PushEvent"}}, "size": 0} | ||
| expected: | ||
| responses: | ||
| - status: 404 | ||
| --- | ||
| endpoint: "_msearch" | ||
| method: POST | ||
| ndjson: | ||
| - {"index":"idontexist", "ignore_unavailable": true} | ||
| - {"query" : {"match" : { "type": "PushEvent"}}, "size": 0} | ||
| expected: | ||
| responses: | ||
| - hits: | ||
| total: | ||
| value: 0 | ||
| status: 200 | ||
|
Member
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. nit: please add missing new line |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| endpoint: "idontexist/_search" | ||
| params: | ||
| q: "*" | ||
| status_code: 404 | ||
| --- | ||
| endpoint: "idontexist/_search" | ||
| params: | ||
| q: "*" | ||
| ignore_unavailable: "true" | ||
| expected: | ||
| hits: | ||
| total: | ||
| value: 0 | ||
| --- | ||
| endpoint: "gharchive-*,idontexist/_search" | ||
| params: | ||
| q: "*" | ||
| status_code: 404 | ||
| --- | ||
| endpoint: "gharchive-*,idontexist/_search" | ||
| params: | ||
| q: "*" | ||
| ignore_unavailable: "true" | ||
| expected: | ||
| hits: | ||
| total: | ||
| value: 4 | ||
|
|
||
|
|
||
|
|
||
|
Member
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. Please, remove the extra empty lines and insert the missing new line. Your editor can do that automatically. |
||
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.