我有这样的映射:
{
"post": {
"properties": {
"author_gender": {
"type": "string",
"index": "not_analyzed",
"omit_norms": true,
"index_options": "docs"
},
"author_link": {
"type": "string",
"index": "no"
},
"content": {
"type": "string"
},
"mentions": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"profile_image_url": {
"type": "string"
},
"screen_name": {
"type": "string"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要按mentions对象的大小进行搜索.我试过这个:
{
"filter": {
"script": {
"script": "doc['mentions'].values.length == 2"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用.给出错误
嵌套:ElasticSearchIllegalArgumentException [在使用类型[post]的映射中找不到[提及]的字段];
我也试过替换脚本部分doc['mentions.id'].value.length == 2.这也是错误的
嵌套:ArrayIndexOutOfBoundsException [10];
如何查询mentions对象大小为2的记录?
Sai*_*Sai 13
elasticsearch指南建议使用size()而不是对象的长度.试试这个:
{
"filter": {
"script": {
"script": "doc['mentions.id'].values.size() == 2"
}
}
}
Run Code Online (Sandbox Code Playgroud)
祝一切顺利.
| 归档时间: |
|
| 查看次数: |
6837 次 |
| 最近记录: |