Filter Search Index

Zachary Perry asked on November 21, 2016 20:25

The OTB intranet solution that uses community groups creates a search index for each group, then only allows searching from within each group.

I want to have a global search that will search inside each of these groups (using custom search indexes).

My questions is, is there a way to filter these search indexes (custom webpart is fine) before searching? Currently I am checking if the user is in the group in the transformation of the results, and either displaying or not displaying the result. Which leads to some pages having like 3 results, and another page having 10.

Guessing it would be something around the Searchparameters, but not sure if I can pass in a where condition, or if I should just modify the results after I get them back:

 DataSet results = SearchHelper.Search(parameters);

Correct Answer

Zachary Perry answered on November 29, 2016 19:52

Here is how I solved the issue:

I used a search condition on the Search Results web part.

I created a custom macro to build a search condition for the current user (GroupID:100 OR GroupID:122 )

Then since I also have an index for pages on the site, I add this to the condition: DocumentID:[0 TO 99999999]

Looks like this in the field on the webpart: +({% GetSearchConditions(CurrentUser.UserID) #%} OR DocumentID:[0 TO 99999999])

Result will be something like this: +(GroupID:100 OR GroupID:122 OR DocumentID:[0 TO 99999999])

1 votesVote for this answer Unmark Correct answer

Recent Answers

Michal Samuhel answered on November 22, 2016 09:01

Hi Zach,

When you mention, that you are using multiple custom indexes, why not create a custom search web part (customizing default one) and use SearchIndexes property of SearchParameters class? You could do the same as in transformation in codebehind of the webpart and based on that alter parameters of search by adding and removing indexes.

0 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on November 22, 2016 16:07


Thanks for the reply. The reason being is one search index will pull content across multiple groups, but I have a custom field that has the groupID, in the transformation I am just checking if the user is in that group.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.