Is it possible to get response with highlighted "_source" instead of "highlight" collection? Is it possible to get response with highlighted "_source" instead of "highlight" collection? elasticsearch elasticsearch

Is it possible to get response with highlighted "_source" instead of "highlight" collection?


It is not possible, since highlighting is a feature available with the search api but doesn't replace your search results.

You need to get the snippets from the highlighted results, and fall back to the _source if there are no snippets available for the fields you are interested in. The recently introduced no_match_size parameter might be useful to you though, as it allows to include in the highlighted results the first part of a field if there was nothing to highlight, so that the fallback is effectively done by elasticsearch itself internally.