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)

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

Signed-off-by: Gao Binlong <[email protected]>

* modify changelog

Signed-off-by: Gao Binlong <[email protected]>

* Add comment and remove unit test

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
  • Loading branch information
gaobinlong authored May 10, 2024
1 parent 48da1b8 commit f28e673
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 @@ -24,6 +24,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 f28e673

Please sign in to comment.