Home > OS >  nested object under path ['somepath'] is not of nested type
nested object under path ['somepath'] is not of nested type

Time:09-28

I am getting the following error when I try to query the data

Error

[nested] nested object under path [existing_contacts] is not of nested type

Data in index

{
        "_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 [email protected]",
              "username" : "UmerShahbaz"
            }
          ],
          "new_contacts" : [ ]
        }
      }

Query

"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": {}
                }
              }
            }
          }
        }
      ]
    }
  }

P.S

This was working before. AWS elastic search domain went down and I have to replace it with the new domain. Now getting this error. Any help would be appreciated. Thanks in advance.

Mapping

{
  "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"
      }
    }
  }
}

CodePudding user response:

You need to create a mapping for your index. That mapping can be applied on index creation or threw an index template. index template You can also do it manually using kibana. By going to menu Stack management->Index management->index template

  • Related