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

Support for value_count aggregation using script #185

Open
sn00011 opened this issue Apr 14, 2015 · 1 comment
Open

Support for value_count aggregation using script #185

sn00011 opened this issue Apr 14, 2015 · 1 comment

Comments

@sn00011
Copy link

sn00011 commented Apr 14, 2015

For now, there is only option 'field' available, but not 'script':

Counting the values generated by a script:

{
...,

"aggs" : {
    "grades_count" : { "value_count" : { "script" : "doc['grade'].value" } }
}

}

http://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-aggregations-metrics-valuecount-aggregation.html#_script_7

@sn00011
Copy link
Author

sn00011 commented Apr 14, 2015

Currently i am using something like this get around this issue:

type ScriptAggregate struct {
    Script string `json:"script"`
}

func (d *AggregateDsl) ValueCountByScript(script string) *AggregateDsl {
    d.Type = ScriptAggregate{Script: script}
    d.TypeName = "value_count"
    return d
}

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