Group scripted fields of many document in one

Hi !

i have some scripted field that i want to group in one document/field

here's an example of my scripts response:

    {
        "_index" : "data-index",
        "_type" : "_doc",
        "_id" : "661316070591028_3503977856324821",
        "_score" : 3.1959937,
        "fields" : {
          "created_time" : [
            "2021-01-10T16:30:00+0000"
          ],
          "media_type" : [
            "photo"
          ],
          "sum" : [
            62.0
          ]
        }
      }

i know that i can move my script to aggregation, but which one is there like a "container" that does do anything.

i want the response to look like this

    [
     {
        "created_time" : [
            "2021-01-10T16:30:00+0000"
          ],
          "media_type" : [
            "photo"
          ],
          "sum" : [
            62.0
          ]
     },
     {
        "created_time" : [
            "2021-01-10T16:30:00+0000"
          ],
          "media_type" : [
            "photo"
          ],
          "sum" : [
            62.0
          ]
     }
    ]

thnx for helping.

I am not sure I understand what the problem is. Could you please show an example of what your data look like, what the query you are running looks like and how the current response differs from what you are looking for?

It is also generally always a good idea to state which version of the stack you are using.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.