Show only the results with specific field as true

Is there’s a way that I could refine my results by a specific value of the items in the index?

For example:

I’ve items in the index like the below stucture:

    "item_name": "Some Random Item 0",
    "is_dispatched": true,
    "item_name": "Some Random Item 1",
    "is_dispatched": true,
    "item_name": "Some Random Item 2",
    "is_dispatched": false,

I need to display only the items which has is_dispatched value as true when I my search query is the value of any items with the search attribute as item_name.

Need some solution.



To filter records depending on a field you need to use Facet Filters.

After you set is_dispatched in attributesForFaceting you can do that'search query here', {
  facetFilters: [
}).then(({ hits }) => {