Skip to content

Commit

Permalink
Fix get field mapping API returns 404 error in mixed cluster with mul…
Browse files Browse the repository at this point in the history
…tiple versions (#13624) (#13625)

* Fix get field mapping API returns 404 error in mixed cluster with multiple versions



* modify changelog



* Add comment and remove unit test



---------


(cherry picked from commit f28e673)

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 3ab8754 commit 070cbac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Fixed
- Fix negative RequestStats metric issue ([#13553](https://github.com/opensearch-project/OpenSearch/pull/13553))
- Fix get field mapping API returns 404 error in mixed cluster with multiple versions ([#13624](https://github.com/opensearch-project/OpenSearch/pull/13624))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -116,6 +117,11 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
String index = in.readString();
if (in.getVersion().before(Version.V_2_0_0)) {
int typesSize = in.readVInt();
// if the requested field doesn't exist, type size in the received response from 1.x node is 0
if (typesSize == 0) {
indexMapBuilder.put(index, Collections.emptyMap());
continue;
}
if (typesSize != 1) {
throw new IllegalStateException("Expected single type but received [" + typesSize + "]");
}
Expand Down

0 comments on commit 070cbac

Please sign in to comment.