0

With the planned removal of mapping types coming to ElasticSearch, does this also mean the deprecation of nested documents and nested queries? How would/will ElasticSearch support queries of nested objects in typeless context?

The functionality I'm considering is being able to return only the hits in a nested array that match search criteria.

Edit 1: Example mapping + query in ElasticSearch version 6

ElasticSearch 6 Mapping

{
    "rec": {
        "mappings": {
            "history": {
                "properties": {
                    "dateCompleted": {
                        "type": "keyword"
                    },
                    "dateCreated": {
                        "type": "keyword"
                    },
                    "dateOrdered": {
                        "type": "keyword"
                    },
                    "dateToArrive": {
                        "type": "keyword"
                    },
                    "details": {
                        "type": "nested",
                        "properties": {

                            "clientId": {
                                "type": "keyword"
                            },
                            "company": {
                                "type": "text",
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            },
                            "orderNumber": {
                                "type": "text",
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

ElasticSearch 6 Query

{
  "from": 0,
  "query": {
    "nested": {
      "inner_hits": {},
      "path": "details",
      "query": {
        "bool": {
          "must": [
            {
              "match_phrase": {
                "details.company.keyword": {
                  "query": "ABCD"
                }
              }
            }
          ]
        }
      }
    }
  },
  "size": 10,
  "sort": [],
  "_source": false
}
2
  • I don't think it would have impact on this, I would like to try that, for that it would be great if you can share ur mapping, sample docs and query, btw +1 for good question Commented Feb 18, 2020 at 6:48
  • Thanks, @es-enthu. I added a stripped-down example mapping and query to hopefully demonstrate how it is working in ElasticSearch 6. Commented Feb 18, 2020 at 7:03

2 Answers 2

2

No, the removal of _type has no impact on nested documents and queries.

In the past, people used different types in one index for modeling serveral entities. The problem was, that some of the entities had the same field but different field type. For example "version", in one entity an string but integer in other. This caused a problem, because there is no solution for this scenario.

EDIT: Nested objects is an mapping dataype for modeling complex properties within a document like this:

{
  "_id" : "12345",
  "user" : { "login":"foo", "email":"[email protected]"}
}

Please note the user object within the document itself or the "details" property in your mapping above. More examples are available here: https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html

The document doctype is a set of properies defining a documents structure by its mapping.

In the past, there was the possibility of modelling a "car" and a "plane" in one index using two doctypes. In current versions there is just one doctype, mainly named _doc and it will be completely removed in future versions.

In the documentation you've linked (removal of types) there is a good example of multi doctype twitter index defining a user and tweet doctype in one index.

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

1 Comment

So is the PUT API not being removed at /_mapping? How would you specify that a field is nested? How would you query to determine if a field was nested? The NEST wrapper library has removed the GetMapping call. elastic.co/guide/en/elasticsearch/client/net-api/current/…
0

It looks like the GetMapping method on the NEST client in versions 7+ has moved to IElasticSearchClient.Indicies.GetFieldMapping. My misunderstanding was that all types were being removed. In reality, it seems like the plan is to just have one type per index. Thanks @ibexit for the clarification.

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.