Elasticsearch Script merge the results of two aggregations

I use aggregrations on elasticsearch version 1.3.8. I use aggregation script for awhile today ıt didnt work. Please help ı cant find any solution :

This the mapping:

  "mappings": {
     "product": {
        "properties": {
           "brandId": {
              "type": "integer"
           },
           "brandIsActive": {
              "type": "boolean"
           },
           "brandLink": {
              "type": "string",
              "index": "not_analyzed"
           },
           "brandName": {
              "type": "string",
              "index": "not_analyzed"
           }

      }

   }

}

this my query:

post alias-test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value",
"size": 0
}
}
}
}

This is the error:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[g][mizu-20150219142655][0]: RemoteTransportException[[Mammomax][inet[/172.31.37.148:9300]][search/phase/query+fetch]]; nested: SearchParseException[[mizu-20150219142655][0]: query[ConstantScore(:)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match_all":{}},"aggs":{"Brand":{"terms":{"script":"doc['brandName'].value"}}}}]]]; nested: ExpressionScriptCompilationException[Field [brandName] used in expression must be numeric]; }]",
"status": 400
}

The other query :

post test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value+'|'+doc['brandLink'].value",
"size": 0
}
}
}
}

the error :

post test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value+'|'+doc['brandLink'].value",
"size": 0
}
}
}
}

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1af39cb0-893d-4a7d-b9e1-a061eed48de6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I second error :

{
"error": "SearchPhaseExecutionException[Failed to execute phase
[query_fetch], all shards failed; shardFailures {[g][test][0]:
RemoteTransportException[[Mammomax][inet[/192.168.1.8:9300]][search/phase/query+fetch]];
nested: SearchParseException[[test][0]:
query[ConstantScore(:)],from[-1],size[-1]: Parse Failure [Failed to
parse source [{"query":{"match_all":{}},"aggs":{"Brand":{"terms":{"script":"doc['brandName'].value+'|'+doc['brandLink'].value","size":0}}}}]]];
nested: ExpressionScriptCompilationException[Failed to parse
expression: doc['brandName'].value+'|'+doc['brandLink'].value];
nested: ParseException[ unexpected character ''' at position (23).];
nested: NoViableAltException; }]",
"status": 400
}

2015-02-19 14:49 GMT+02:00 ali balci balci.alii@gmail.com:

I use aggregrations on elasticsearch version 1.3.8. I use aggregation script for awhile today ıt didnt work. Please help ı cant find any solution :

This the mapping:

  "mappings": {
     "product": {
        "properties": {
           "brandId": {
              "type": "integer"
           },
           "brandIsActive": {
              "type": "boolean"
           },
           "brandLink": {
              "type": "string",
              "index": "not_analyzed"
           },
           "brandName": {
              "type": "string",
              "index": "not_analyzed"
           }

      }

   }

}

this my query:

post alias-test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value",
"size": 0
}
}
}
}

This is the error:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[g][mizu-20150219142655][0]: RemoteTransportException[[Mammomax][inet[/172.31.37.148:9300]][search/phase/query+fetch]]; nested: SearchParseException[[mizu-20150219142655][0]: query[ConstantScore(:)],from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"match_all":{}},"aggs":{"Brand":{"terms":{"script":"doc['brandName'].value"}}}}]]]; nested: ExpressionScriptCompilationException[Field [brandName] used in expression must be numeric]; }]",
"status": 400
}

The other query :

post test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value+'|'+doc['brandLink'].value",
"size": 0
}
}
}
}

the error :

post test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value+'|'+doc['brandLink'].value",
"size": 0
}
}
}
}

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/aeNWfgYNVmA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/1af39cb0-893d-4a7d-b9e1-a061eed48de6%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/1af39cb0-893d-4a7d-b9e1-a061eed48de6%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Best Regards

ALİ BALCI
Bilgisayar Mühendisligi
Tel:0543 699 59 88
FACEBOOK http://www.facebook.com/alibalci.mail
BLOG http://balciali.wordpress.com/

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMLQj%3D%2B1k0DiPwXdtxYNMjcK%2BMeQmzSAdw-9D0nrVpP-mPU4nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

Looks like you are using lucene expression [1]. See the link for the limitation of lucene expression. Today it only supports numeric values.
Since terms agg doesn’t have lang property, probably you have “script.default_lang" set to “expression" in elasticsearch.yml?

FYI, if you put “lang”:”groovy” (and if configuration allows running dynamic groovy script), your query should work.
But make sure you read release note [2] before turning on dynamic groovy scripting. (you can use groovy script without turning on dynamic scripting [3])

Masaru

[1] Elasticsearch Platform — Find real-time answers at scale | Elastic
[2] Elasticsearch Platform — Find real-time answers at scale | Elastic
[3] Elasticsearch Platform — Find real-time answers at scale | Elastic

On February 19, 2015 at 22:21:41, ali balci (balci.alii@gmail.com) wrote:

I second error :

{
"error": "SearchPhaseExecutionException[Failed to execute phase
[query_fetch], all shards failed; shardFailures {[g][test][0]:
RemoteTransportException[[Mammomax][inet[/192.168.1.8:9300]][search/phase/query+fetch]];
nested: SearchParseException[[test][0]:
query[ConstantScore(:)],from[-1],size[-1]: Parse Failure [Failed to
parse source [{"query":{"match_all":{}},"aggs":{"Brand":{"terms":{"script":"doc['brandName'].value+'|'+doc['brandLink'].value","size":0}}}}]]];
nested: ExpressionScriptCompilationException[Failed to parse
expression: doc['brandName'].value+'|'+doc['brandLink'].value];
nested: ParseException[ unexpected character ''' at position (23).];
nested: NoViableAltException; }]",
"status": 400
}

2015-02-19 14:49 GMT+02:00 ali balci :

I use aggregrations on elasticsearch version 1.3.8. I use aggregation script for awhile
today ıt didnt work. Please help ı cant find any solution :

This the mapping:

"mappings": {
"product": {
"properties": {
"brandId": {
"type": "integer"
},
"brandIsActive": {
"type": "boolean"
},
"brandLink": {
"type": "string",
"index": "not_analyzed"
},
"brandName": {
"type": "string",
"index": "not_analyzed"
}

}

}

}

this my query:

post alias-test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value",
"size": 0
}
}
}
}

This is the error:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query_fetch],
all shards failed; shardFailures {[g][mizu-20150219142655][0]: RemoteTransportException[[Mammomax][inet[/172.31.37.148:9300]][search/phase/query+fetch]];
nested: SearchParseException[[mizu-20150219142655][0]: query[ConstantScore(:)],from[-1],size[-1]:
Parse Failure [Failed to parse source [{"query":{"match_all":{}},"aggs":{"Brand":{"terms":{"script":"doc['brandName'].value"}}}}]]];
nested: ExpressionScriptCompilationException[Field [brandName] used in expression
must be numeric]; }]",
"status": 400
}

The other query :

post test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value+'|'+doc['brandLink'].value",
"size": 0
}
}
}
}

the error :

post test/product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"Brand": {
"terms": {
"script": "doc['brandName'].value+'|'+doc['brandLink'].value",
"size": 0
}
}
}
}

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/aeNWfgYNVmA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/1af39cb0-893d-4a7d-b9e1-a061eed48de6%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.

--
Best Regards

ALİ BALCI
Bilgisayar Mühendisligi
Tel:0543 699 59 88
FACEBOOK
BLOG

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAMLQj%3D%2B1k0DiPwXdtxYNMjcK%2BMeQmzSAdw-9D0nrVpP-mPU4nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.54e6d79d.3a95f874.10ad%40citra.local.
For more options, visit https://groups.google.com/d/optout.