- Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Closed
Copy link
Labels
:Search/SearchSearch-related issues that do not fall into other categoriesSearch-related issues that do not fall into other categoriesbug"" muted="" aria-describedby="MDU6TGFiZWwyMzE3Mw==-tooltip :R5b96b:">>bugTeam:SearchMeta label for search teamMeta label for search team
Description
Elasticsearch Version
8.7.1
Installed Plugins
No response
Java Version
openjdk 20.0.1 2023-04-18
OS Version
Linux 80ea76b172b2 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
Problem Description
After upgrading from ES 8.6.2 to 8.7.1 I noticed that params['_source'] value is wrong sometimes when it's accessed in runtime_mappings field's script as in:
"runtime_mappings": { "runtime_field": { "type": "keyword", "script": { "lang": "painless", "source": "emit(params['_source'].toString())" } } } Steps to Reproduce
PUT foo_bar { "mappings": { "properties": { "id": { "type": "text" }, "name": { "type": "text", "fields": { "raw": { "type": "keyword" } } } } }, "settings": { "index": { "number_of_shards": 3, "number_of_replicas": 2 } } } POST foo_bar/_bulk?refresh=true {"index":{}} {"id":"1","name":"name 1"} {"index":{}} {"id":"2","name":"name 2"} {"index":{}} {"id":"3","name":"name 3"} {"index":{}} GET foo_bar/_search { "size": 0, "runtime_mappings": { "runtime_field": { "type": "keyword", "script": { "lang": "painless", "source": "emit(params['_source'].toString())" } } }, "fields": [ "runtime_field" ], "aggs": { "aggregation": { "terms": { "field": "name.raw" }, "aggs": { "hits": { "top_hits": { "_source": true } } } } }, "from": 0 } and result of this is:
{ "took": 1, "timed_out": false, "_shards": { "total": 3, "successful": 3, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 3, "relation": "eq" }, "max_score": null, "hits": [] }, "aggregations": { "aggregation": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "name 1", "doc_count": 1, "hits": { "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 1, "hits": [ { "_index": "foo_bar", "_id": "TydRSIgB3P4C-UmlKFF0", "_score": 1, "_source": { "id": "1", "name": "name 1" }, "fields": { "runtime_field": [ "{id=1, name=name 1}" ] } } ] } } }, { "key": "name 2", "doc_count": 1, "hits": { "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 1, "hits": [ { "_index": "foo_bar", "_id": "UCdRSIgB3P4C-UmlKFF0", "_score": 1, "_source": { "id": "2", "name": "name 2" }, "fields": { "runtime_field": [ "{id=2, name=name 2}" ] } } ] } } }, { "key": "name 3", "doc_count": 1, "hits": { "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 1, "hits": [ { "_index": "foo_bar", "_id": "USdRSIgB3P4C-UmlKFF0", "_score": 1, "_source": { "id": "3", "name": "name 3" }, "fields": { "runtime_field": [ "{id=1, name=name 1}" # <----- It should be "{id=3, name=name 3}" ] } } ] } } } ] } } } Please let me know if you need more info to investigate this
Logs (if relevant)
No response
Metadata
Metadata
Assignees
Labels
:Search/SearchSearch-related issues that do not fall into other categoriesSearch-related issues that do not fall into other categoriesbug"" muted="" aria-describedby="MDU6TGFiZWwyMzE3Mw==-tooltip :Ra5pmb:">>bugTeam:SearchMeta label for search teamMeta label for search team