How to Restrict searchableAttributes from being Fetched in React

I have a react app that has named_tags in the Algolia Index. I have three tags, phrase_en, phrase_jp, and phrase_cn. I have added these three tags as searchableAttributes in the Algolia Indices. My question is, how can I restrict in code side (react side) the phrase_en attribute from being searched at?

I have tried:

<Configure
        restrictSearchableAttributes={['named_tags.phrase_en']}
/>

in the InstantSearch but still, the string inside named_tags.phrase_en is still considered as a search attributes.

For example:

Item 1
named_tags.phrase_en:hello
named_tags.phrase_jp:konnichiwa
named_tags.phase_ch:nihao

If I search “hello”, the item 1 should not come out but now, it does come out even though I have restrictSearchableAttributes for the named_tags.phrase_en.

I need the three named_tags to be in the searchableAttributes in Algolia because they are. It only depends on what language the user has selected.

Hi James,

If I search “hello”, the item 1 should not come out but now, it does come out even though I have restrictSearchableAttributes for the named_tags.phrase_en

Declaring a searchable attribute in named_tags.phrase_en means that only matches in those attributes will yield results. So, in your example, where named_tags.phrase_en is declared in restrictSearchableAttributes, typing “hello” should retrieve the record, because there’s a match in named_tags.phrase_en. However, if you type “koni”, you won’t have a match because named_tags.phrase_jp isn’t listed in restrictSearchableAttributes.

See a reproduction using the Algolia dashboard:

If you’re trying to exclude named_tags.phrase_en, then you should list named_tags.phrase_jp and named_tags.phrase_cn in restrictSearchableAttributes.

Also, please note that you can’t use restrictSearchableAttributes on an attribute that’s part of a comma-separated list of attributes within searchableAttributes (that is, attributes declared with the same level of priority). If you do this, the engine will throw an error.

Thanks Dayan. I was confused at first.

Hello @sarah.dayan , can someone also help me on this query? How to Pass More Parameters in connectHits(CustomHit) thanks