Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to transform Elasticsearch mutiple aggregation TopN #71

Open
weidongcao opened this issue Sep 8, 2019 · 0 comments
Open

How to transform Elasticsearch mutiple aggregation TopN #71

weidongcao opened this issue Sep 8, 2019 · 0 comments

Comments

@weidongcao
Copy link

weidongcao commented Sep 8, 2019

in Elasticsearch I have to query with mutiple aggregation, result like this:

[
    {
        "field_name1": "field_name1_value1",
        "field_name2": "field_name2_value1",
        "count": 2
        "topN": [{"name": "aaa"},{"name": "bbb"}]
    },
    {
        "field_name1": "field_name1_value2",
        "field_name2": "field_name2_value2",
        "count": 2
        "topN": [{"name": "ccc"},{"name": "ddd"}]
    },
    {
        "field_name1": "field_name1_value1",
        "field_name2": "field_name2_value2",
        "count": 3
        "topN": [{"name": "eee"},{"name": "fff"},{"name": "ggg"}]
    }
]

I hope transform it like this :

{
	"field_name1_value1": {
		"field_name2_value1": {
			"count": 2,
			"topN": [{"name": "aaa"},{"name": "bbb"}]
		},
		"field_name2_value2": {
			"count": 3,
			"topN": [{"name": "eee"},{"name": "fff"},{"name": "ggg"}]
		}
	},
	"field_name1_value2": {
		"field_name2_value2": {
			"count": 2,
			"topN": [{"name": "ccc"},{"name": "ddd"}]
		}
	}
}

how could I do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant