below is index mapping
{
"lm_dsp_data_search_funnel-2018.08.10": {
"mappings": {
"doc": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"abtest": {
"type": "keyword"
},
"adlist": {
"type": "nested",
"properties": {
"promotionid": {
"type": "integer"
},
"sn": {
"type": "integer"
}
}
},
"adxid": {
"type": "keyword"
},
"age": {
"type": "integer"
},
"deviceidmd5": {
"type": "keyword"
},
"displocal1": {
"type": "integer"
},
"displocal2": {
"type": "integer"
},
"escount": {
"type": "long"
},
"gender": {
"type": "integer"
},
"interest": {
"type": "integer"
},
"mediaid": {
"type": "integer"
},
"os": {
"type": "integer"
},
"sid": {
"type": "keyword"
},
"sidcount": {
"type": "integer"
},
"slotid": {
"type": "integer"
},
"stime": {
"type": "long"
},
"styleids": {
"type": "integer"
},
"tags": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"userip": {
"type": "keyword"
}
}
}
}
}
}
expression is below
GET lm_dsp_data_search_funnel-2018.08.10/_search
{
"size": 10,
"query": {
"bool": {
"must": [
{
"match": {
"adxid": "u-2cbc34ryk3v43nkdq9g"
}
},
{
"range": {
"stime": {
"gte": 1533859200000,
"lte": 1533873600000
}
}
}
],
"filter": {
"script": {
"script": "doc['adlist'].values.length > 0"
}
}
}
},
"aggs": {
"sn_count": {
"sum": {
"field": "sidcount"
}
}
}
}
I want to add a query is that adlist.size > 0 .
here is the response:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:81)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)",
"doc['adlist'].length > 0",
" ^---- HERE"
],
"script": "doc['adlist'].length > 0",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "lm_dsp_data_search_funnel-2018.08.10",
"node": "gIcfga4kTZq7A4XI1dHC0A",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:81)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)",
"doc['adlist'].length > 0",
" ^---- HERE"
],
"script": "doc['adlist'].length > 0",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "No field found for [adlist] in mapping with types []"
}
}
}
]
},
"status": 500
}
thanks for your answer!