0

I have the data in the following structure

"mappings" : {
            "PERSON" : {
                "properties" : {
                    "ADDRESS" : {
                        "type": "nested",
                        "properties" : {
                        "STREET" : {
                            "type": "nested",
                            "properties" : {
                                "street": {
                                    "type": "string"
                                },
                                "number": {
                                "type": "integer"
                                }
                            }
                        },
                        "CITY" : {
                            "type": "nested",
                            "properties" : {
                                "name": {
                                    "type": "string"
                                },
                                "size": {
                                "type": "integer"
                                }
                            }
                        }
                        ,
                        "country": {
                            "type": "string"
                        }
                        }
                    },
                    "INFORMATION" : {
                        "type": "nested",
                        "properties" : {
                        "age": {
                            "type": "integer"
                        },
                        "sex": {
                            "type": "string"
                        }
                        }
                    }
                    "name" : {
                        "type": "string",
                    }
                }
            }
        }

I want to aggregate nested object dynamically in form: ["object type": count of records with this type].

e.g. for the PERSON I want to get something like:

[ADDRESS: 1000, INFORMATION: 1230]

and for ADDRESS:

[STREET: 200, CITY: 100]

Is it possible?

1 Answer 1

1

You can first filter based on PERSON or ADDRESS and then use cardinality aggregation to get the count

Sign up to request clarification or add additional context in comments.

1 Comment

what filter I have to use on PERSON to get ADDRESS and INFORMATION?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.