[BUG] Since OpenSearch 2.12, when using flat_object, the error Preview of field's value: 'null' occurs. #13184
Closed
Description
Describe the bug
I'm using flat_object
with OpenSearch.
In OpenSearch 2.12 or later, an error occurs if the field name to be registered in flat_object
has more than 10 digits.
Related component
Indexing
To Reproduce
- Register an index template.
curl -X PUT "http://localhost:9200/_index_template/test" \
-H "Content-Type: application/json" \
-d '
{
"index_patterns": [
"test-*"
],
"template": {
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"properties": {
"data": {
"type": "object",
"properties": {
"detail": {
"type": "flat_object"
}
}
}
}
}
},
"data_stream": {
"timestamp_field": {
"name": "@timestamp"
}
}
}
'
- Register data in the following format.
curl -X POST "http://localhost:9200/_bulk" \
-H "Content-Type: application/x-ndjson" \
-d '
{"create":{"_index":"test-2024.04.15"}}
{"@timestamp": "2023-10-20T18:46:28Z", "data":{"detail":{"foooooooooo":[{"name":"baz"},{"name":"baz"}]}}}
'
- The following error occurs in OpenSearch 2.12 or later.
{
"took":3,
"errors":true,
"items":[
{
"create":{
"_index":".ds-test-2024.04.15-000001",
"_id":"IEAB3o4Bu0tRxJSPrze4",
"status":400,
"error":{
"type":"mapper_parsing_exception",
"reason":"failed to parse field [data.detail] of type [flat_object] in document with id 'IEAB3o4Bu0tRxJSPrze4'. Preview of field's value: 'null'",
"caused_by":{
"type":"string_index_out_of_bounds_exception",
"reason":"String index out of range: -1"
}
}
}
}
]
}
I'm getting an internal error String index out of range: -1
, so I tried renaming the fooooooooooo
field (11) to fooooooooooo
(10) and that solved the error.
Expected behavior
The error does not occur until 2.11.
{
"took":23,
"errors":false,
"items":[
{
"create":{
"_index":".ds-test-2024.04.15-000001",
"_id":"wFIK3o4BVRoqI_57sTFZ",
"_version":1,
"result":"created",
"_shards":{
"total":1,
"successful":1,
"failed":0
},
"_seq_no":1,
"_primary_term":2,
"status":201
}
}
]
}
Additional Details
Plugins
Please list all plugins currently enabled.
Screenshots
If applicable, add screenshots to help explain your problem.
Host/Environment (please complete the following information):
- OS: [e.g. iOS]
- Version [e.g. 22]
Additional context
The problem is occurring using Data Streams, but the same problem is reproduced without Data Streams.