Display comments depends on user's groupID

How can I display comment for groupA properly ?
I want comments to be shown depends on user’s shareClientGroupId.

There are the list what I’m trying to do now.

1.newsStartupShareList.clientGroupId Agroup → ABGroupVirtuleap is searchable.(done)
2.newsStartupShareList.clientGroupId Agroup or Bgroup → ABGroupVirtuleap is searchable.(done)
3.newsStartupShareList.clientGroupId Cgroup → ABGroupVirtuleap is not searchable(done)

4.commentList.shareClientGroupId Agroup → ABGroupVirtuleap is searchable、and Agroup comment must be searchable but B is not( I’m stuck here.)

  1. combine condition both newsStartupShareList.clientGroupId and commentList.shareClientGroupId to make sure it displays and hides as expected.


Hi @ynaka,

I’m not sure I’ve completely understood your issue. Let me recap to be sure we are on the same page. Your records contain a list of comments. Each of those comments is attached to a group of clients (i.e. shareClientGroupId). This field is set as attributesForFaceting to be able to build the RefinementList displayed on the left of the screen.

The behavior that you would expect is that when a group ID is selected from the RefinementList only those comments are returned from Algolia. Is it correct? e.g. AGroup is selected so only the comments from the AGroup are returned.

Let me know if I understood the problem correctly!

Hi,
basically what I want to do is like differentiating what users can see as their status like VIP, premier, standard membership.

So you can think as shareClientGroupId as user’s targets to share their posts.
newStartupShareListId as user status like VIP, premier, standard membership but they’re just A,B and C this time.

In the picture, shareClientGroupId A is selected but Comments for B is also shown which is not good.

Hi @ynaka,

Ok got it! Thank you for the explanation.

I doubt you can achieve what you want with the current structure of your records. Algolia can’t return a partial field of your records. The only way I can think of at the moment is to show/hide the comments at render time in the clients. Note that it won’t really solve your problem because all the data are returned from the API. It means that a user has access to all the data whatever its status.

The recommended approach would be to flatten the comment in the index i.e. one record for each comment. You can then control which comment to return. I don’t how it fits in your architecture but that would be the way to go. The alternative is to leverage a separate index.

Hope that helps!