Varying the score acording to search word

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Varying the score acording to search word

Luis Neves-3

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.

Example:

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?

Thanks!

Luis Neves
Reply | Threaded
Open this post in threaded view
|

Re: Varying the score acording to search word

Luis Neves-3

Mental note: think before post ... this is a simple job for a Servlet filter.
sorry for the noise.

--
Luis Neves



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.
>
> Example:
>
> 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?
>
> Thanks!
>
> Luis Neves
>

Reply | Threaded
Open this post in threaded view
|

Re: Varying the score acording to search word

Chris Hostetter-3
In reply to this post by Luis Neves-3

: 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...

  +(regularText:doll adultText:doll) +(category:Family adultText:doll)

...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
this case...

  +(regularText:aphrodisiac adultText:aphrodisiac) +(category:Family adultText:aphrodisiac)

...aphrodisiac will never be in regularText, so only adult products will
match.

assuming you want strict matching, you can extend it to work with
multi-word input using something like...

  +(regularText:(sex doll) adultText:(sex doll) +(category:Family adultText:(sex doll))

...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.



-Hoss