Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Search result filtering based on visitor group

Vote:
 

If I have a piece of content (e.g. a html block) a user will not see when he is not part of a visitor group, I can still search for this content and get the page on which the content resides as a search result. Is there any to prevent this from happening? The situation I now have is that a user can search a specific search term, get a result, but he will never see the search term on the page in the search result, because he will not see the content (block) containing the search term.

#172339
Nov 30, 2016 16:11
Vote:
 

Hi Mathijis,

If I understand correctly, you want to only show search results for a visitor group. If you are not a part of the group, you don't see the results, correct? If that is the case, you can use: .FilterForVisitor(). so, here is a snippet to see it in action:

ITypeSearch<ISearchContent> query = _client.UnifiedSearchFor(searchText);

var TypeFilter = _client.BuildFilter<PageData>().FilterForVisitor();

query = query.Filter(TypeFilter);

var results = query.Skip((page - 1) * pageSize).Take(pageSize).GetResult();

return results;

I hope this helps.

Thanks!

John

#172342
Edited, Nov 30, 2016 16:45
Vote:
 

Thanks for the quick reply. However, this doesn't work, and that's exactly the problem.

I don't need to add a FilterForVisitor, because by default GetResult includes a FilterForPublicSearch which in its turn includes the FilterForVisitor. But nevertheless I did try to add a FilterForVisitor, and it didn't change the results.

Somehow FilterForVisitor will only filter out pages you don't have access to. I my case the user does have access to the page but his vistitorgroup membership prevents him from seeing a certain piece of content on this page. But searching for this specific piece of content does include the page in the search results.

#172353
Dec 01, 2016 8:25
Vote:
 

Hi Mathijis,

So, that is an interesting problem. I spoke to a very skilled and knowledgeable colleague of mine and he recommended that, since Find doesn't index any context of a visitor, you shouldn't index the block in question. He said that as a general rule of thumb, you shouldn't index personlized areas. 

Thanks!

John

#172440
Dec 02, 2016 16:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.