Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically flatten objects when subobjects: false #88934

Closed
Tracked by #96651
felixbarny opened this issue Jul 29, 2022 · 5 comments · Fixed by #97972
Closed
Tracked by #96651

Automatically flatten objects when subobjects: false #88934

felixbarny opened this issue Jul 29, 2022 · 5 comments · Fixed by #97972
Assignees
Labels
>enhancement :Search/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team

Comments

@felixbarny
Copy link
Member

Currently, when an object is mapped with subobjects: false, trying to ingest a document that has nested objects leads to a mapping exception.

In a couple of occasions, we've been talking about that it would be convenient if Elasticsearch could automatically flatten the fields instead of the client having to know about the subobjects setting. This would make subobjects: false more of a drop-in replacement that allows for a much easier adoption, without changes in the client.

Note that the _source should ideally stay untouched, just the stored fields should be flattened automatically.

Some related issues

@felixbarny felixbarny added the :Search/Mapping Index mappings, including merging and defining field types label Jul 29, 2022
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Jul 29, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@javanna
Copy link
Member

javanna commented Aug 3, 2022

Note that the _source should ideally stay untouched, just the stored fields should be flattened automatically.

Correct, the idea is that the _source would stay the same, only the corresponding mapping representation would change, so that intermediate objects would not be dynamically mapped as such, but rather only the leaf fields would be mapped with their full path as their name instead.

Note that this is only about incoming documents. Incoming mappings can't hold objects whenever subobjects is set to false, and that will stay as-is.

@felixbarny
Copy link
Member Author

felixbarny commented Aug 3, 2022

Not sure if I understand this correctly:

Incoming mappings can't hold objects whenever subobjects is set to false, and that will stay as-is.

Did you mean that trying to explicitly map a property as type: object doesn't work if subobjects is false? That's what I would have expected. Or is there something more than that?

@eyalkoren
Copy link
Contributor

eyalkoren commented Jun 8, 2023

Are there cases that will require special handling?
For example, given this mapping:

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

one can ingest a location as follows:

PUT my-index-000001/_doc/1
{
  "location": { 
    "lat": 41.12,
    "lon": -71.34
  }
}

Should there be special handling so that such won't be automatically flattened?

@javanna
Copy link
Member

javanna commented Jun 8, 2023

special handling so that such won't be automatically flattened?

The special handling would be done by Elasticsearch based on mappings definition. This is one of the complex aspects that made us consider this a feature of Elasticsearch as opposed to implemented on the client side: you can't blindly flatten everything on the sender side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team
Projects
None yet
5 participants