【发布时间】:2019-09-18 06:14:25
【问题描述】:
我正在尝试在 Elasticsearch 6.1.2 上提取具有 2 个或更多嵌套对象的文档。
我们的索引有这样一个简单的映射。
{
"organizations": {
"type": "nested",
"properties": {
"id": {
"type": "text"
}
"name": {
"type": "text"
}
}
}
我们想提取具有 2 个或更多组织的文档。
像这样
{
"organizations": [
{
"id" : "1",
"name" : "company A"
},
{
"id" : "2",
"name" : "company B"
}
]
}
一些文章说无痛脚本查询对这种情况很有用,
所以我希望可以通过以下查询来实现这一点
{
"query": {
"nested": {
"path": "organizations",
"query": {
"bool": {
"must": {
"script": {
"script": {
"inline": "doc['organizations'].length > 1",
"lang": "painless"
}
}
}
}
}
}
}
}
但 Elasticsearch 说
{
"caused_by": {
"type": "illegal_argument_exception",
"reason": "No field found for [organizations] in mapping with types [top]"
}
}
您能否给我一些关于如何实现这一目标的想法?欢迎任何想法或选择。
非常感谢。
【问题讨论】:
标签: elasticsearch elasticsearch-painless