Skip to content

Commit 2f1bcce

Browse files
committed
_fieldcaps API: Clear field.indices if it matches global indices
1 parent 8d06ceb commit 2f1bcce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

quickwit/quickwit-serve/src/elastic_search_api/model/field_capability.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct FieldCapabilityEntryResponse {
9898
// Option since it is filled later
9999
#[serde(rename = "type")]
100100
typ: Option<FieldCapabilityEntryType>,
101+
#[serde(skip_serializing_if = "Vec::is_empty")]
101102
indices: Vec<String>, // [ "index1", "index2" ],
102103
#[serde(skip_serializing_if = "Vec::is_empty")]
103104
non_aggregatable_indices: Vec<String>, // [ "index1" ]
@@ -164,6 +165,13 @@ pub fn convert_to_es_field_capabilities_response(
164165
for field_type in types {
165166
let mut add_entry = add_entry.clone();
166167
add_entry.typ = Some(field_type.clone());
168+
169+
// If the field exists in all indices, we omit field.indices in the response.
170+
let exists_in_all_indices = add_entry.indices.len() == indices.len();
171+
if !exists_in_all_indices {
172+
add_entry.indices = Vec::new();
173+
}
174+
167175
entry.insert(field_type, add_entry);
168176
}
169177
}

0 commit comments

Comments
 (0)