这是我的es语句
POST xxx/_search
{
"size":100,
"query": {
"bool" : {
"must" : [
{
"script" : {
"script" : {
"inline": "doc['createTime'].getDate().getMonthOfYear() == 11",
"lang": "painless"
}
}
}
]
}
}
}
查询的时候报如下错误
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['createTime'].getDate().getMonthOfYear() == 11",
" ^---- HERE"
],
"script": "doc['createTime'].getDate().getMonthOfYear() == 11",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "yimi_crm_label_info",
"node": "YXl5mywNT9yX3SrXMK2BsA",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['createTime'].getDate().getMonthOfYear() == 11",
" ^---- HERE"
],
"script": "doc['createTime'].getDate().getMonthOfYear() == 11",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [org.elasticsearch.index.fielddata.ScriptDocValues.Dates, getDate/0] not found"
}
}
}
]
},
"status": 400
}
createTime是date类型。看了很多技术文档都是这样写的,不知道我这里哪里有问题。还请大佬指教
POST xxx/_search
{
"size":100,
"query": {
"bool" : {
"must" : [
{
"script" : {
"script" : {
"inline": "doc['createTime'].getDate().getMonthOfYear() == 11",
"lang": "painless"
}
}
}
]
}
}
}
查询的时候报如下错误
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['createTime'].getDate().getMonthOfYear() == 11",
" ^---- HERE"
],
"script": "doc['createTime'].getDate().getMonthOfYear() == 11",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "yimi_crm_label_info",
"node": "YXl5mywNT9yX3SrXMK2BsA",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['createTime'].getDate().getMonthOfYear() == 11",
" ^---- HERE"
],
"script": "doc['createTime'].getDate().getMonthOfYear() == 11",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [org.elasticsearch.index.fielddata.ScriptDocValues.Dates, getDate/0] not found"
}
}
}
]
},
"status": 400
}
createTime是date类型。看了很多技术文档都是这样写的,不知道我这里哪里有问题。还请大佬指教
3 个回复
fish_to_sky
赞同来自:
core_wzw - 某AILab搜索技术负责人
赞同来自:
https://elasticsearch.cn/question/3649
mobikarl
赞同来自:
GET kibana_sample_data_ecommerce/_search
{
"size": 100,
"query": {
"bool": {
"must": [
{
"script": {
"script": {
"source": "doc['order_date'].value.getMonthValue()==11",
"lang": "painless"
}
}
}
]
}
}
}