morsecoder
morsecoder

Reputation: 1659

Relative Performance of ElasticSearch on inner fields vs outer fields

All other things being equal, including indexing, I'm wondering if it is more performant to search on fields closer to the root of the document.

For example, lets say we have a document with a customer ID. Two ways to store this:

{
  "customer_id": "xyz"
}

and

{
  "customer": {
    "id": "xyz"
  }
}

Will it be any slower to search for documents where "customer.id = 'xyq'" than to search for documents where "customer_id = 'xyz'" ?

Upvotes: 0

Views: 53

Answers (1)

Val
Val

Reputation: 217554

That's pure syntactic sugar. The second form, i.e. using object type, will be flattened out and internally stored as

"customer.id": "xyz"

Hence, both forms you described are semantically equivalent as far as what gets indexed into ES, i.e.:

"customer_id": "xyz"
"customer.id": "xyz"

Upvotes: 3

Related Questions