0

I just have this simple question.

I've been putting my mind into how nested fields work in elasticsearch. There is not many resources out there specifically talking about what uses cases it's good for. I get that it's useful for querying a document with an array-like field, and that the nested field saves in the same way as the document itself.


I was wondering about extreme cases of gigantic arrays within a document, like a comment section, or unique "views" for a post. Would a nested field for such arrays speed up the querying? Would it not matter at all?

3
  • Arrays are flattened and it is faster that way. If you need to maintain independence of each inner object of array only then you need to use nested type. Check this stackoverflow.com/questions/69202516/… Commented Sep 19, 2021 at 11:22
  • @jaspreetchahal Are you implying that it doesn't matter if it's nested or not compared to performance of arrays? Commented Sep 19, 2021 at 12:15
  • 1
    Nested type will be slow as compared to object type. Actual different though depends on size of data. If you don't need any relationship between individual values in array then object type is fine otherwise nested type is needed which has overheads. If you will check ink in my previous answer you will understand difference in how these work Commented Sep 20, 2021 at 4:36

0

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.