Access field that was excluded from _source

Hi,

As mentioned in the title, I have an index with a few fields that are not included in the _source field.

I was wondering, since we can still search on these fields, is there a way to access their values?

One solution I explored was adding the store mapping property, but this does not seem to work with dense_vector fields.

However, since we can still search on these fields using a normal query or on vector fields using a knn query, is there a method to retrieve the values of these fields?

Kind regards,
Chenko Mortier

Hi there @Chenko!

No, unfortunately if you do not include fields in _source it saves space by not storing it in a way that is retrievable. This impacts using the update, update_by_query and reindex APIs as well as highlighting as a result.

It's searchable because it's still part of the inverted index.

A recommended solution is to keep content in source but use source filtering instead.

You could also look at synthetic source however note that this is in tech preview for dense_vector fields.

1 Like

Hi @Kathleen_DeRusso thanks for your reply!

That is unfortunate.

That's what I was afraid of.

I thought this would not improve performance, will this still improve performance?
For example when excluding the KNN field at search time, will this have better performance than not doing this, also how does this compare to excluding it at ingest time?

I will take a look at synthetic source, thanks for this suggestion!

Correct, this will not improve performance as the documents are still in _source

Ah okay, makes sense. Thanks.

About the synthetic source, would this improve performance, or make it slower?
I seem to read it makes it slower, or am I misunderstanding this?

Correct - it's more of a space saving optimization.

1 Like

Okay thanks for the additional help.