Skip to content

Commit c2c7320

Browse files
Dedupe index names when returning search response (#10850)
* Dedupe index names when returning search response Signed-off-by: Amardeepsingh Siglani <[email protected]> * Changeset file for PR #10850 created/updated --------- Signed-off-by: Amardeepsingh Siglani <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent a2ea7a2 commit c2c7320

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

changelogs/fragments/10850.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- Dedupe index names for data selection ([#10850](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10850))

src/plugins/data/public/query/query_string/dataset_service/lib/index_type.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,17 @@ const fetchIndices = async (dataStructure: DataStructure): Promise<string[]> =>
231231
return [];
232232
}
233233

234-
return rawResponse.aggregations.indices.buckets.map((bucket: { key: string }) => {
234+
const uniqueResponses = new Set<string>();
235+
rawResponse.aggregations.indices.buckets.forEach((bucket: { key: string }) => {
235236
const key = bucket.key;
236237
// Note: Index names cannot contain ':' or '::' in OpenSearch, so these delimiters
237238
// are guaranteed not to be part of the regular format of index name
238239
const parts = key.split(DELIMITER);
239240
const lastPart = parts[parts.length - 1] || key;
240241
// extract index name or return original key if pattern doesn't match
241-
return lastPart.split(':')[0] || key;
242+
uniqueResponses.add(lastPart.split(':')[0] || key);
242243
});
244+
return Array.from(uniqueResponses);
243245
};
244246

245247
return search

0 commit comments

Comments
 (0)