Skip to content

Terms Script Aggregation #92

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

Open
IdanWo opened this issue Aug 30, 2018 · 2 comments
Open

Terms Script Aggregation #92

IdanWo opened this issue Aug 30, 2018 · 2 comments

Comments

@IdanWo
Copy link

IdanWo commented Aug 30, 2018

Is it possible to make a terms aggregation on a scripted field which isn't the root? Kibana's terms aggregation demands choosing a field. Maybe when a script is provided (through input JSON or through a dedicated field), there should be a support when choosing a field to find the relevant nested level.

{
	"aggs" : {
		"myNested" : {
			"path" : "Cars"
		},
		"aggs" : {
			"MyTerms" : {
				"terms" : {
					"script" : {
						"source" : "doc['Cars.Type'].value + '-' + doc['Cars.Model'].value",
						"lang" : "painless"
					}
				}
			}
		}
	}
}

This support seems (to me) very related to issue #89. In both issues, the field is specified only in order to drill down into the desired nested level.

Implementation details:

  • The same key of field might be confusing. How can the plugin know whether to make a terms aggregation on the specified field or just to drill down into it? I think it's best to make a new type of aggregation called Terms Script Aggregation, which is different from the regular Terms Aggregation.
  • Another decision would be whether to include a parameter named source or just to include the script in the input JSON. I think the latter option is far more flexible.

Kibana version: 5.6.10.

@ppadovani
Copy link
Owner

Hmm.. I haven't dived into the scripted support fully yet. In Kibana currently you can script a field by editing the index pattern and adding it there. You may be able to add a scripted field there, then be able to use that within a terms aggregation, but I haven't tested that.

@ppadovani
Copy link
Owner

I'm going to call this an enhancement, and bucket into the set of tasks I have on deck for the next version of the plugin.

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

No branches or pull requests

2 participants