Filter Documents with multiple values in it's field

Manohar reddy vangala asked on June 6, 2017 16:56

I have Document type with field name "Type" where i am storing multiple values into it with pipe(|) seperated, Now i want to filter the documents using smart search filter how can i achive this.

The values in the field as follows: 45|78|89|56

Correct Answer

Mike Wills answered on June 6, 2017 19:30

This looks like a perfect case for a tokenized field in SmartSearch. I've created solutions almost the same way. All you need is to ensure the field is analyzed in a way that each value is treated as a search term. This would allow you to do a property search for any of the values like this: Type:78.

The format using the pipe delimited might be a challenge. The SmartSearch analyzer may not treat pipe characters as "word breaks". So, the index might have "45|78|89|56" as one term. You can check by opening the Smart Search index in the Lucene index viewer, Luke. http://www.getopt.org/luke/

  1. If the values are not being treated as separate terms, you have a few options. If you can, changing the delimiter to a space character would work.
  2. If you cannot change the delimiter, you may have to handle the Document_GetContent_Execute global event, so that you can control how the new field is indexed. You could even replace the pipes with spaces before passing the value to the indexer. I've used the SearchHelper.AddGeneralField method with success.
1 votesVote for this answer Unmark Correct answer

Recent Answers


Ilesh Mistry answered on June 6, 2017 17:29

Are those values in the Type field, going to be the filter options for people to select?

This is a great place to start with Smart Search filters Smart Search Filters

Then making sure you set the page type field (search fields) to be tokenised and/or searchable.

0 votesVote for this answer Mark as a Correct answer

Matthew Henninger answered on June 9, 2017 20:37 (last edited on June 9, 2017 21:55)

If you click on the arrow next to the value separator field you can use this macro {%return " "%} to set the delimiter as a space in the form control.

0 votesVote for this answer Mark as a Correct answer

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