i wanna use aggs and script in es 6.3 like below
GET /trxdetail-sdall/_search?pretty
{
"aggs": {
"distinct_OPPNAME": {
"terms": {
"script":"doc['OPPACC']+' '+doc['OPPNAME']"
}
}
},
"query": {
"terms": {
"OPPACC.keyword": [
"629005281011"
]
}
}
}
but the result is
"caused_by": {
"type": "illegal_argument_exception",
"reason": "cannot execute scripts using [aggs] context",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "cannot execute scripts using [aggs] context"
}
my setting in elasticsearch.yml is
script.allowed_types: inline
script.allowed_contexts: search, update
my question is how to set the config for using script in aggs? or there is no ways in using script for aggs?
Try This
{
"aggs": {
"distinct_OPPNAME": {
"terms": {
"script": "doc['OPPACC'].value + ' ' + doc['OPPNAME'].value"
}
}
},
"query": {
"terms": {
"OPPACC.keyword": [
"629005281011"
]
}
}
}
thanks for reply。 i try it but the same result
"caused_by": {
"type": "illegal_argument_exception",
"reason": "cannot execute scripts using [aggs] context",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "cannot execute scripts using [aggs] context"
}
}
i think mybe it is the setting problem in elasticsearch.yml?
rjernst
(Ryan Ernst)
August 30, 2018, 3:27pm
4
There should be a full stack trace in your logs. Can you add that here?
rjernst
(Ryan Ernst)
August 30, 2018, 3:29pm
5
Also, you explicitly have only search
and update
scripts allowed in your elasticsearch.yml
. You need to add aggs
there if you want to do terms aggregations:
script.allowed_contexts: search, update, aggs
kennymarx0
(Huangkai)
September 2, 2018, 11:25am
6
thanks for reply.
my setting is
script.allowed_types: inline
script.allowed_contexts: search,update,aggs
and used the script like below, then success! thanks alot .
GET /trxdetail-sdall/_search?pretty
{
"aggs": {
"distinct_OPPNAME": {
"terms": {
"script": "doc['OPPACC.keyword'].value + ' ' + doc['OPPNAME.keyword'].value"
}
}
},
"query": {
"terms": {
"OPPACC.keyword": [
"629005281011"
]
}
}
}
system
(system)
Closed
September 30, 2018, 11:25am
7
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.