You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Otis Gospodnetic <ot...@yahoo.com> on 2006/09/21 23:51:21 UTC

Fixed first hits -> custom RequestHandler?

Hello,

I have a situation where I want certain documents to appear at the top of the hit list for certain searches, regardless of their score.  One can think of it as the ads right on top of Google's search results (but I'm not dealing with ads).

Example:
If I'm searching books in a bookstore, and a person is searching for "lucene", the owner of the bookstore may want to promote the recently published "Lucene in Action" instead of some other book about Lucene, so he wants any search for "lucene" or "java search" to put the link to "Lucene in Action" on top.

Is there a good way to accomplish this in Solr?
My initial thoughts are that it would be best to have an external store, maybe even a Lucene index.  This store would host the data to display on top of hits, as well as keywords/phrases that would have to match user's search terms.  A custom RequestHandler would then perform a regular search (a la any of the existing RequestHandlers), plus pull the data from this side store, and stick those in the response.

Is this a good candidate for a custom RequestHandler?

Thanks,
Otis




Re: Fixed first hits -> custom RequestHandler?

Posted by Tim Archambault <ta...@bangordailynews.net>.
Otis,

I'm curious as to what you find out here. I'm looking at setting up a
second Solr instance to handle keyword advertising and the first
instance to handle the site search for our newspaper website. Never
thought of your question.

Thanks,

Tim

On 9/21/06, Otis Gospodnetic <ot...@yahoo.com> wrote:
> Hello,
>
> I have a situation where I want certain documents to appear at the top of the hit list for certain searches, regardless of their score.  One can think of it as the ads right on top of Google's search results (but I'm not dealing with ads).
>
> Example:
> If I'm searching books in a bookstore, and a person is searching for "lucene", the owner of the bookstore may want to promote the recently published "Lucene in Action" instead of some other book about Lucene, so he wants any search for "lucene" or "java search" to put the link to "Lucene in Action" on top.
>
> Is there a good way to accomplish this in Solr?
> My initial thoughts are that it would be best to have an external store, maybe even a Lucene index.  This store would host the data to display on top of hits, as well as keywords/phrases that would have to match user's search terms.  A custom RequestHandler would then perform a regular search (a la any of the existing RequestHandlers), plus pull the data from this side store, and stick those in the response.
>
> Is this a good candidate for a custom RequestHandler?
>
> Thanks,
> Otis
>
>
>
>

Re: Fixed first hits -> custom RequestHandler?

Posted by Yonik Seeley <yo...@apache.org>.
On 9/21/06, Yonik Seeley <yo...@apache.org> wrote:
> You could make anything with an isSpecial boolean field appear first:
> search_field:java; score desc, special desc

Oops, that should be
  search_field:java; special desc, score desc
"score desc" should be the secondary sort, or whatever you normally
want to sort by.

-Yonik

Re: Fixed first hits -> custom RequestHandler?

Posted by Chris Hostetter <ho...@fucit.org>.
: On 9/21/06, Otis Gospodnetic <ot...@yahoo.com> wrote:
: > I have a situation where I want certain documents to appear at the top
: of the hit list for certain searches, regardless of their score.  One
: can think of it as the ads right on top of Google's search results (but
: I'm not dealing with ads).

the kind of approach Yonik described works well when you really want the
"boosted" documents (ie: ads, promoted products, etc) to be inlcuded in
the main paginated flow of results, regardless of how many there are.

if you want them to be broken out (like the ads google shows in the right
nav of their pages) so that they aren't affected by pagination or sorting
changes; or if you want a limited number to appear (ie: bubble the 3
highest scoring promoted products up to the top, but leave the rest of the
promoted products where they are in the normally sorted list) then i don't
know any way arround this except executing two searches.

I've typically done it by making two Solr requests from the client, but
you could also do this will a custom request handler that included two
DocLists in the results.

(now that you can progromatically modify/override the params of a
SolrQueryRequest, it would be really easy to write a subclass of any
existing request handler that first did the "promo" search, and then
delegated to the super class with "fq" params telling it to ignore the
results you've already included)



-Hoss


Re: Fixed first hits -> custom RequestHandler?

Posted by Yonik Seeley <yo...@apache.org>.
On 9/21/06, Otis Gospodnetic <ot...@yahoo.com> wrote:
> I have a situation where I want certain documents to appear at the top of the hit list for certain searches, regardless of their score.  One can think of it as the ads right on top of Google's search results (but I'm not dealing with ads).

You could make anything with an isSpecial boolean field appear first:
search_field:java; score desc, special desc

The "special" field could even be an int field so you could control
the order that the special docs appeared.

You could also do something with boosting:
+(search_terms:java) special:true^100

If you have special search terms you want to associate with a doc, you
can have another field for that and boost it highly... that would give
you a measure of relevancy among "special" documents:

normal_search_field:java  special_search_field:java^100

> Is this a good candidate for a custom RequestHandler?

Hopefully all the tools are already there to do this w/o extra code.

-Yonik

Re: Fixed first hits -> custom RequestHandler?

Posted by Joachim Martin <jm...@path-works.com>.
How about a sortOrder field?  Then you can sort by "sortOrder, score".

If you want to promote a book that might not be in the result set, you'd 
OR the featured books in with the query.

--Joachim

Otis Gospodnetic wrote:

>Hello,
>
>I have a situation where I want certain documents to appear at the top of the hit list for certain searches, regardless of their score.  One can think of it as the ads right on top of Google's search results (but I'm not dealing with ads).
>
>Example:
>If I'm searching books in a bookstore, and a person is searching for "lucene", the owner of the bookstore may want to promote the recently published "Lucene in Action" instead of some other book about Lucene, so he wants any search for "lucene" or "java search" to put the link to "Lucene in Action" on top.
>
>Is there a good way to accomplish this in Solr?
>My initial thoughts are that it would be best to have an external store, maybe even a Lucene index.  This store would host the data to display on top of hits, as well as keywords/phrases that would have to match user's search terms.  A custom RequestHandler would then perform a regular search (a la any of the existing RequestHandlers), plus pull the data from this side store, and stick those in the response.
>
>Is this a good candidate for a custom RequestHandler?
>
>Thanks,
>Otis
>
>
>  
>