Mental note: think before post ... this is a simple job for a Servlet filter.
sorry for the noise.
Luis Neves wrote:
> Hello all.
> We have a product catalog that is searchable via Solr, by default we
> want to exclude results from the "Adult" category unless the search
> terms match a predetermined list of words.
> Client searches for "doll", "doll" is not on the list -> we *don't want*
> to show him Adult results.
> Client searched for "aphrodisiac", "aphrodisiac" is on the list -> we
> *want* to show him Adult results.
> Did I made sense?
> FunctionQuery seems to be what I want, but it's not clear to me how to
> use it in this particular case.
> Can anyone point me in the right direction?
> Luis Neves
: We have a product catalog that is searchable via Solr, by default we want to
: exclude results from the "Adult" category unless the search terms match a
: predetermined list of words.
I ment to reply to this yesterday and forgot ... the most straightforward
way to deal with tis (as i think you found) is external to Solr ... if you
identify one of the words in your input as denoting an adult category,
then add "category:Adult" to your query.
But another option, is to identify words in products which are adult
themed when indexing the products, and put them in a seperate adultText
field, then structure your queries like this...
...since "doll" is considered a familar frendly word, it would never
appear in adultText, so no adult products would match, just ones in the
Family category that had "doll" in the regular text field, meanwhile in
...sex would only ever be in aultTeext, doll would only ever be in
regularText, so only adult products would match, but they would still be
required to have the word doll in them. (boosting on exact phrase matches
could still be done, using an optional phrase query on a third field
containing all of the text)
...all of which is really a lot of work that doesn't make much sense --
if you have a way of identifying "adult" words, you might as well do it
at query time instead of index time -- but it is possible.