Structure of document affect speed?

I have a question out of curiosity. Does the structure of the document have any effect on the indexing and searching speed in an index?

Would e.g.

"user": {
       "id":"123",
       "first_name":"John",
       "last_name":"Doe"
}

take longer time than

{
"user_id":"123",
"user_first_name":"John",
"user_last_name":"Doe"
}

?

In the example case I know the potential difference be miniscule, but imagine you have millions of docs with loads of nested data, would it have anything to say?

Unless you set up custom mappings using the nested field type, the internal representation is going to be flattened to this:

{
  "user.id": "123",
  "user.first_name": "John",
  "user.last_name": "Doe"
}

It's functionally equivalent to the document on the bottom, so there should be no difference in performance.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.