Nested vs Encoded Array

Currently, my mapping queries against an array of nested objects with 3 fields (call them A, B, and C). Our query pattern either filters by (A), by (A & B), or by (A, B, & C). We also may perform a terms aggregation on C when filtered to (A) or (A & B).

Given that we never filter by (B) or (C) individually, I am curious whether it may be more performant to change from the nested object array to a single array encoding the values together, for instance: ["A", "A:B", "A:C", "A:B:C"], and then using the same encoding scheme when querying. Regarding the terms aggregation, I would need to either use a script to prune the terms to only those starting with the filtered encoding, or I could calculate for all terms and then prune the result set. I'm not sure which would be more performant.

However, is this an over optimization?

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