2

I have some indexed data in elastic search, I am trying to use postman to get the data using the below request.

{
"_source": ["_id"],
"query":  {
    "nested" : {
        "path" : "data",
        "query" : {
            "bool" : {
                "must" : [
                { "match" : {"data.id": "3456"} }
                ]
            }
        },
        "score_mode" : "avg"
    }
}

}

But I am getting the exception

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

My mapping definition is like

    {
  "property": {
    "mappings": {
      "property": {
        "properties": {
          "data": {
            "properties": {
              "id": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "point": {
            "properties": {
              "lat": {
                "type": "float"
              },
              "lon": {
                "type": "float"
              }
            }
          },
          "popId": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

Any idea why it is happening ?

7
  • Please share your mappings definition Commented Nov 13, 2019 at 13:24
  • @AssaelAzran added mapping def. Commented Nov 13, 2019 at 13:31
  • What is your elastic version? and where is destinations nested object in your mappings? Commented Nov 13, 2019 at 13:34
  • version is 6.7.0 Commented Nov 13, 2019 at 13:35
  • Robin please add a copy-paste of the real mapping ( from GET <your_index>/_mapping . What you added seems to be a "handwritten" mapping. Plus: you certainly did not add the correct query to your question since the error mentions a "destination" path when your query to not mention it. Commented Nov 13, 2019 at 13:38

1 Answer 1

2

Field data is an object so it should be of type nested.

Nested Type

Try these mapping configurations instead:

PUT property
{
  "mappings": {
    "property": {
      "properties": {
        "point": {
          "properties": {
            "lat": {
              "type": "float"
            },
            "lon": {
              "type": "float"
            }
          }
        },
        "popId": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "data": {
          "type": "nested",
          "properties": {
            "id": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      }
    }
  }
}

You will have to delete your index and recreate it with the new mapping configurations.

If you don't want to delete your data this might help

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.