elastic / elastic/elasticsearch
Output in API responses is inconsistent / not in order
- Dominant language
- Java
- Stars
- 77.9k
- Forks
- 26.1k
- PR merge metrics
- PR metrics pending
Description
### Elasticsearch Version
8.8.1
### Installed Plugins
_No response_
### Java Version
_bundled_
### OS Version
5.4.0-52-generic
### Problem Description
As a user managing configuration of Elasticsearch assets as code, I noticed that there are positional differences in API response fields (and I suspect in array values too, but did not investigate further to validate that).
It seems like while we use ` java.util.NavigableMap` in most places, API responses are not in order (or at least consistent).
As an example, check this positional shift of `number_of_replicas` in that index settings response;
```diff
index 87b35d0683f..4e86b7ce772 100644
@@ -5,8 +5,13 @@
"lifecycle": {
"name": "apm-rollover-30-days"
},
+ "number_of_replicas": "1",
"number_of_shards": "3",
- "number_of_replicas": "1"
+ "routing": {
+ "allocation": {
+ "total_shards_per_node": "2"
+ }
+ }
}
}
}
```
### Steps to Reproduce
Create an index, change the settings mentioned above, get index settings a few times and you should notice the inconsistency.
### Logs (if relevant)
_No response_
Contributor guide
Research direction
Start by reproducing the index-settings request described in the issue and compare repeated API responses, focusing on field ordering and the suspected array ordering. Trace the response serialization path to identify where ordering becomes inconsistent; done means repeated responses have stable ordering and regression coverage verifies it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100