Elasticsearch 嵌套查询映射的 DynamoDb 数据 returns 无

Elasticsearch nested query over mapped DynamoDb data returns nothing

我已经在 Elasticsearch 中映射了来自 DynamoDb 的数据。我想 return 一个通过嵌套数据查询它的文档。我对最简单的嵌套查询有疑问:

{
  "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": [

    ]
  }
}

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

UPD

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

好吧,几天后发现当对象数组包含看起来不像 {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"
          }
        }
      ]
    }
  }
}