Fetching one field from every inner hit (docvalue_field VS source filtering)

Hi,

I have an index that stores complex documents with multiple nested fields, but as a query result I always need only one field from the nested document (some uid).
How should I do: just turn off the _source and take the values using docvalue_field, or storing _source and get values from it using source filtering?
Which of the two options is better?
I hope for your help.

1 Like

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

This is coming quite late, but I wanted to link to a new reference page we're adding that gives some guidance on when to use source filtering vs. docvalue_fields: Add a reference on returning fields during a search. by jtibshirani · Pull Request #57500 · elastic/elasticsearch · GitHub.

How should I do: just turn off the _source and take the values using docvalue_field, or storing _source and get values from it using source filtering?

If you really only need one value in the response, and it's available from doc values, then it could be more efficient to load it using docvalue_fields instead of source filtering. If you don't use the _source elsewhere, then you could disable it to save space. It's important to know that certain features will no longer work when the _source isn't stored, such as reindex, source-only snapshots, and highlighting (in some cases).

1 Like