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

Generating terms using a script #1910

Closed
jimmyjones2 opened this issue Nov 13, 2014 · 3 comments
Closed

Generating terms using a script #1910

jimmyjones2 opened this issue Nov 13, 2014 · 3 comments

Comments

@jimmyjones2
Copy link
Contributor

Tried the following JSON input as a simple test of generating terms using a script in the visualize aggregation builder:

{ "script" : "doc['gender'].value" }

but got a fatal error (GroovyScriptExecutionException[ArrayIndexOutOfBoundsException[null]. I think this is because Kibana is still sending the term field, which should be omitted with this kind of script.

I did get a value script to work:

{ "script" : "'Test: '+_value" }
@w33ble
Copy link
Contributor

w33ble commented Nov 13, 2014

You can use the JSON input in the aggregations, but only when you are querying the same field you selected in the builder since field is part of the agg.

If you're looking for script fields, #1537 and #1755 cover this, and are being worked on now.

Can you provide your specific use case here though? What you aggregation looks like and what you're trying to do with the JSON input could be useful.

@jimmyjones2
Copy link
Contributor Author

My use case was trying to work around #1911 where I had empty aggregations that I wanted to show. The workaround idea was to aggregate over a field value, but if it didn't exist return a default value instead, so the bucket would never be empty with something like:

{ "script" : "doc['gender'].value ?: 'unknown'" }

If I understand correctly, this is pretty much what those issues talk about.

@w33ble
Copy link
Contributor

w33ble commented Nov 17, 2014

Yeah, this will be possible when we have better support for scripted fields. It also sounds like #1926 might be a better solution to your immediate issue. Given all this, I'm going to go ahead and close this issue. If you have specific comments related to scripted fields, you can add them to #1537

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

2 participants