Aggregation with nested properties

Hello,
I have the mapping below:

mappings:
properties:
    companyId:
        type: long
    customFields:
        type: nested
        properties:
            id:
                type: long
            customFieldId:
                type: long
            value:
                type: text
                fielddata: true
                analyzer: lower_analyzer
                fields:
                    keyword:
                        type: keyword
                        ignore_above: 256

i am try to make an aggregate with the customField properties like this:

{
  "query": {
  "match_all": {}
  },
  "size": 0, 
  "aggs": {
    "customFields": {
        "nested": {
        "path": "customFields"
      },
      "aggs": {
        "aggregateResulte": {
          "terms": {
            "script": "doc['customFields.customFieldId'] + ','+ doc['customFields.value']",
            "size": 10
          }
        }
      }
    }
  }
}

I would like to match exactly customField propertie include the number of size.

Register I => [ customFiedId => 191, value = "serge"]
Register II => [ customFiedId => 191, value = "serge"]
Register III => [ customFiedId => 191, value = "serge", customFiedId => 192, value = "serge", ]
Register IV => [ customFiedId => 190, value = "serge", customFiedId => 192, value = "serge1", ]
Register V => [ customFiedId => 191, value = "serge", customFiedId => 192, value = "serge", ]

the result exepeted should be
bucket I => Register I and Register II
bucket II => Register III and Register V

Because there are the same value and the same number of object, but my request doesn't work well. Like Register III have one value, it appears on the bucket I even the dimension is 2.

thank

Some body can help me ?

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