Native script support in TermsStatsFacet query

(Hanish Bansal) #1

Hi All,

I have registered some custom java based scripts using native script
support in elasticsearch.

Now i am able to use those script using below query:

"query" : {
"match_all" : { }
"script_fields": {
"MessageReverted": {
"script": "reverse",
"lang": "native",
"params": {
"field": "field1"

Where reverse is my script name that is defined in elasticsearch.yml as:

script.native.reverse.type :

I am able to get expected results.

Now i want similar functionality in facet functions. I am using term stat
facet query

By default TermsStatsFacet query supports below functions:

    Text getTerm();

    Number getTermAsNumber();

    long getCount();

    long getTotalCount();

    double getMin();

    double getMax();

    double getTotal();

    double getMean();

TermsStatsFacet query is really useful feature to compute stats on a field. I
am already using it in some of my use cases. One of my use case is also to
compute some custom stats on a field.

Is there any way to register some custom functions to these using native
scripts or any other method ?

Thanks in advance !!

Thanks & Regards
Hanish Bansal

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

(system) #2