node.js - 路径 ['somepath' 下的嵌套对象] 不是嵌套类型

标签 node.js elasticsearch aws-lambda elasticsearch-5

当我尝试查询数据时出现以下错误

错误

[nested] 路径 [existing_contacts] 下的嵌套对象不是嵌套类型

索引中的数据

{
        "_index" : "memoreasecontacts",
        "_type" : "_doc",
        "_id" : "614d6f0b2a05640008d09109",
        "_score" : 1.0,
        "_source" : {
          "id" : "614d6f0b2a05640008d09109",
          "existing_contacts" : [
            {
              "is_profile_completed" : true,
              "friend_status" : "pending",
              "email_verified" : false,
              "gender" : "Male",
              "is_new_signup" : "true",
              "religious_id" : [
                {
                  "religious" : "Hinduism",
                  "id" : "5db7d2a36a57364618c57efe"
                }
              ],
              "email_token" : "VZs37yfesXbCsRuWGJPqgZxVn1Xz55Qh",
              "profileImage" : "uploads/userimage.png",
              "deviceId" : [ ],
              "friend_owner" : "receiver",
              "blocked_status" : false,
              "lastname" : "Shahbaz",
              "password" : "$F0EaWeYX=d5#Q3Jld2xvZ2l4QDE=",
              "mobile_verified" : true,
              "created_on" : "2021-09-24T12:49:24.674Z",
              "dob" : "2021-09-24T00:00:00.000Z",
              "selfinformation" : "Testing app",
              "firtsname" : "Umer",
              "id" : "614dc95412b8c0000903cd5c",
              "email" : "m.haris+10@crewlogix.com",
              "username" : "UmerShahbaz"
            }
          ],
          "new_contacts" : [ ]
        }
      }

查询

"query": {
    "bool": {
      "must": [
        {
          "term": {
            "_id": {
              "value": "614d6f0b2a05640008d09109"
            }
          }
        },
        {
          "nested": {
            "ignore_unmapped": true,
            "path": "existing_contacts",
            "query": {
              "bool": {
                "must": [
                  {
                    "match": {
                      "existing_contacts.friend_status": "pending"
                    }
                  },
                  {
                    "match": {
                      "existing_contacts.friend_owner": "receiver"
                    }
                  }
                ]
              }
            },
            "inner_hits": {
              "size": "1",
              "from": "0",
              "highlight": {
                "fields": {
                  "existing_contacts.username": {},
                  "existing_contacts.friend_status": {}
                }
              }
            }
          }
        }
      ]
    }
  }

附言

这之前是有效的。 AWS Elasticsearch 域已关闭,我必须将其替换为新域。现在收到此错误。任何帮助,将不胜感激。提前致谢。

映射

{
  "memoreasecontacts" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "existing_contacts" : {
          "properties" : {
            "blocked_status" : {
              "type" : "boolean"
            },
            "created_on" : {
              "type" : "date"
            },
            "dob" : {
              "type" : "date"
            },
            "email" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "email_token" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "email_verified" : {
              "type" : "boolean"
            },
            "firtsname" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "friend_owner" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "friend_status" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "gender" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "id" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "is_new_signup" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "is_profile_completed" : {
              "type" : "boolean"
            },
            "lastname" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "mobile" : {
              "type" : "long"
            },
            "mobile_verified" : {
              "type" : "boolean"
            },
            "password" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "profileImage" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "religious_id" : {
              "properties" : {
                "id" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "religious" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                }
              }
            },
            "selfinformation" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "username" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1632463671805",
        "number_of_shards" : "5",
        "number_of_replicas" : "1",
        "uuid" : "ckUxjK5wQoOiagEINEwb0w",
        "version" : {
          "created" : "7040299"
        },
        "provided_name" : "memoreasecontacts"
      }
    }
  }
}

最佳答案

您需要为您的索引创建一个映射。该映射可以应用于索引创建或抛出一个索引模板。索引模板 您也可以使用 kibana 手动完成。通过菜单 Stack management->Index management->index template

关于node.js - 路径 ['somepath' 下的嵌套对象] 不是嵌套类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69316193/

相关文章:

java - 尝试将 JpaRepository 注入(inject) AWS Lambda 时没有合格的 bean

c# - serilog通过.net核心中的记录器引用为对象建立索引

email - AWS Lambda : How to extract attachment (xls) from raw email?

node.js - 如何在 node.js 服务器上设置 EV 证书

node.js - 使用 Jest 简单模拟 Passport 功能

regex - 根据Logstash中的另一个字段创建索引

node.js - Node.js弹性客户端getMapping不要给mapp

python - 将 Python 依赖项打包到 AWS Lambda 的子目录中

javascript - 回调返回值但似乎未定义

javascript - 带有代理和域\用户的 node.js http :password authorization