Search code examples
reactivesearch

How to filter _source in reactivesearch?


I need to exclude certain fields from the _source field in the elastic response since those fields are huge and transferring them unnecessarily wastes lots of time. In general, in elastic this is done by providing _source parameter in the query, e.g.:

GET /_search
{
    "_source": { "excludes": [ "content" ] },
    "query" : { ... }
}

Searchkit, for example, does this exclusion for highlighted fields automatically (which would be ideal in my case), but also supports an option for user to provide _source filter irrespective of highlighting too. Reactivesearch DataSearch component seems to be missing this kind of capability.

I can't figure out how to add _source (or any other search parameter) to the reactivesearch DataSearch query. Is that possible?


Solution

  • We currently don't support this behavior in ReactiveSearch, but we should. I have filed an issue for the same https://github.com/appbaseio/reactivesearch/issues/417.

    Edit: This is now supported, you can see how to pass it in the documentation of Result components.