Can separating index and setting couple refinements work differentiate user status?

Is it possible to set refinement and not showing to users ?
I would like to use refinement as user restriction.
For example, a VIP member can see all the posts, but a standard user has limited access.
I do not want to show check box to users.

Hi there,

You can create API keys that has query parameters embedded.
If you put “filters” parameter when generating API keys, clients using this API key cannot remove this filter and keep seeing filtered search result.
By changing API keys based on the users, you can switch the data that your end-users can retrieve.
Please find more detail in the following document.

Another possible idea is to create query rules using rulesContext to add filters.
rulesContext is a parameter which can be passed at query time, and you can create a rule to add query parameters.
You can find more details in the following link:

Please note that rulesContext can be overridden on the client side, so API key restriction seems better in your use case.

Thank you!

I’ve updated codesandbox

What if I would like to filter from 2 indices?
How can I apply attributes from 2 indices indexA indexB ?
I read the documentation but still unclear how to apply indices and filter.

const publicKey = client.generateSecuredApiKey(

‘Our search only api key’,

{

restrictIndices: 'NewStartupIndex,CommentIndex'

}

);

index.search(‘query’, {

facetFilters: [

 'newsStartupShareList.clientGroupId (this is from NewStartupIndex) :CG000000000000020'

 'shareClientGroupId (this is from CommentIndex) :CG000000000000017',

]

}).then(({ hits }) => {

console.log(hits);

});

Hi Tatsuro san.

I am trying to do what you advised and got stuck.

Please advise.

Thank you.

https://discourse.algolia.com/t/apply-filtering-for-one-of-two-indices/11487

This should be doable like this.
However I’m not sure that would work well with 2 index that have different schema.
You should probably generate 2 different api keys (one for each index).

const publicKey = client.generateSecuredApiKey(
  'YourSearchOnlyApiKey',
  {
    restrictIndices: 'NewStartupIndex,CommentIndex',
    filters: 'newsStartupShareList.clientGroupId:CG000000000000020 OR shareClientGroupId:CG000000000000017',
  }
);

I am trying to apply filter but it seems not working.
I don’t get any error at the moment. please advise.
Thanks.