对映射的DynamoDb数据进行Elasticsearch嵌套查询不返回任何内容

问题描述 投票:1回答:1

我在Elasticsearch中映射了DynamoDb中的数据。我想返回一个通过嵌套数据查询它的文档。我有一个最简单的嵌套查询的问题:

{
  "query": {
    "nested": {
      "path": "doc.dynamodb.newImage.childCalls.M",
      "query": {
        "bool": {
          "minimum_should_match": 1,
          "should": [
            {
              "match": {
                "doc.dynamodb.newImage.childCalls.M.caller.S": "+18002427338"
              }
            },
            {
              "match": {
                "doc.dynamodb.newImage.childCalls.M.callee.S": "+18002427338"
              }
            }
          ]
        }
      }
    }
  }
}

看起来我错过了必不可少的东西这是映射:

"childCalls": {
    "properties": {
        "M": {
            "type": "nested",
            "properties": {
                "callee": {
                    "properties": {
                        "S": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                },
                "caller": {
                    "properties": {
                        "S": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                }
            }
        }
    }
}

响应不包含任何错误:

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": [

    ]
  }
}

是的,索引包含我不想返回的文档。我也尝试了caller.S路径,它没有帮助。

UPD

似乎嵌套数据应该是一个{key: value}对象,以正确索引。因此,我需要一个预处理器管道来将用对象表示的值转换为平面值。

elasticsearch amazon-dynamodb dsl
1个回答
0
投票

好的,几天之后,当对象数组包含看起来像{key: string|number|boolean}的对象时,根本不需要嵌套映射。复杂对象不会像docs中描述的那样进行转换,它们看起来像对象数组。这是映射:

"childCalls": {
    "properties": {
        "L": {
            "properties": {
                "M": {
                    "properties": {
                        "callee": {
                            "properties": {
                                "S": {
                                    "type": "string",
                                    "index": "not_analyzed"
                                }
                            }
                        },
                        "caller": {
                            "properties": {
                                "S": {
                                    "type": "string",
                                    "index": "not_analyzed"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

和工作查询:

{
  "query": {
    "bool": {
      "minimum_should_match": 1,
      "should": [
        {
          "match": {
            "doc.dynamodb.newImage.childCalls.L.M.caller.S": "+18002427338"
          }
        },
        {
          "match": {
            "doc.dynamodb.newImage.childCalls.L.M.callee.S": "+18002427338"
          }
        }
      ]
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.