my object shape is:
{
...otherFields,
isApproved: false
}
so I want to fetch all the objects where isApproved is true
Hi @developerk786, you can add arbitrary filters using the configure widget:
<Configure filters="isApproved:true" />
Or the toggleRefinement widget
<ToggleRefinement attribute="isApproved" value={true} />
Ok so it works with instasearch but what about fetching data with algolia client, algolia.getObject()
With getObject you give an objectID, so filtering doesn't make sense anymore at that point, but you can use search() to get one (or more) items based on a condition:
client.search('', {
filters: 'isApproved:true',
hitsPerPage: 1
})
This is of course limited, but if you want to find _all_ items based on a filter, you can use browse: https://www.algolia.com/doc/api-reference/api-methods/browse/
ok that nice but is there any option in algolia dashboard where I can set that thing, pardon my English.
You can not set a filter by default, but what you can do is prefilling an API key with the filter in it, so it can not be removed: https://www.algolia.com/doc/api-reference/api-methods/generate-secured-api-key/
ok thanks for your help