Smart Search index with subset of items

Brenden Kehren asked on July 17, 2017 18:43

Working in Kentico 10 and have a need for a smart search to return 2 different page types but 1 of the page types needs to be limited by only 2 categories. Example:

Resources page type, show all.
News page type, only show news items in category 1 and category 2 and not category 3, 4 or 5.

Resources are not assigned to category 1 - 5.

I could put a default filter hidden on the page but then it will filter out both the resources and news items.

I could create a custom index to handle this but looking for more configuration first before coding.

Recent Answers


Trevor Fayas answered on July 17, 2017 19:13 (last edited on July 17, 2017 19:13)

Hey Brenden, can you upload your Smart Search Index folder (App_Data\CMSModules\SmartSearch\TheIndex) somewhere? With it i can do some testing with LUKE

I believe i can help get a lucene syntax going that would accomplish this. A question would be would it be okay to have this condition "always on" (So if i search for "Test" it will only show results from resources or News w/ category 1/2, or do i need to be able to toggle that logic on and off?)

May be able to do this without a custom filter at best, but at worse a custom filter that will toggle/apply that logic.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 17, 2017 20:50

The ideal scenario is both news and resources page types are intermingled (which is easy) BUT only the news items categorized as Category 1 or Category 2 AND all of the resources are displayed. Should also mention there are other filters on the page already which filter out the current resources.

I've done some searching playing around with Luke and think I have a few options but none are working fully with the other filters on the page.

Regarding toggling, the filter for news items to only ever return category 1 and category 2 items should not be a filter at this particular time.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on July 17, 2017 21:12 (last edited on July 17, 2017 21:22)

If I understand correctly in sql terms: WHERE (classid =1 and categoryid in (123, 456)) or classid = 2

you can probably achieve this with Lucene syntax by putting search condition for your smart search results: +((nodeclassid:(int)1 AND documentcategoryids:(123 456)) OR nodeclassid:(int)2)

3 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on July 17, 2017 21:17

What are the other filters adding to the mix? If you can write the Lucene each is adding, we can try to generate the proper syntax, Peter is on the track i was thinking.

0 votesVote for this answer Mark as a Correct answer

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