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 Floyd Wu <fl...@gmail.com> on 2012/11/28 11:15:27 UTC

Dynamic ranking based on search term

Hi there,

If I have a list that is key-value pair in text filed or database table.
How do I achieve dynamic ranking based on search term? That say when user
search term "java" and doc1,doc2, doc5 will get higher ranking.

for example( key is search term, value is related index document unique
key):
==========
key, value
==========
java, doc1,doc2,doc5
book, doc9, doc4,doc77
==========

I've finished implementation using externalFileField to do ranking, but in
this way, ranking is static.

Please kindly point me a way to do this.

PS: SearchComponent maybe?

Re: Dynamic ranking based on search term

Posted by Floyd Wu <fl...@gmail.com>.
Hi Upayavira

Let me explain what I need in the other words.

The list is the result that after analyzing log.
Key value pairs list actually means that when search term is java, then
boosting these documents(doc1,doc2,doc5).
for example
      java, doc1,doc2,doc5

Any ideas?

Thanks.




2012/11/28 Upayavira <uv...@odoko.co.uk>

> Isn't this what Solr/Lucene are designed to do??
>
> On indexing a document, Lucene creates an inverted index, mapping terms
> back to their containing documents. The data you have is already
> inverted.
>
> I'd suggest uninverting it and then hand it to Solr in that format,
> thus:
>
> doc1: java
> doc2: java
> doc4: book
> doc5: java
> doc9: book
> doc77: book
>
> With that structure, you'll have in your index exactly what Solr
> expects, and will be able to take advantage of the inbuilt ranking
> capabilities of Lucene and Solr.
>
> Upayavira
>
> On Wed, Nov 28, 2012, at 10:15 AM, Floyd Wu wrote:
> > Hi there,
> >
> > If I have a list that is key-value pair in text filed or database table.
> > How do I achieve dynamic ranking based on search term? That say when user
> > search term "java" and doc1,doc2, doc5 will get higher ranking.
> >
> > for example( key is search term, value is related index document unique
> > key):
> > ==========
> > key, value
> > ==========
> > java, doc1,doc2,doc5
> > book, doc9, doc4,doc77
> > ==========
> >
> > I've finished implementation using externalFileField to do ranking, but
> > in
> > this way, ranking is static.
> >
> > Please kindly point me a way to do this.
> >
> > PS: SearchComponent maybe?
>

Re: Dynamic ranking based on search term

Posted by Upayavira <uv...@odoko.co.uk>.
Isn't this what Solr/Lucene are designed to do??

On indexing a document, Lucene creates an inverted index, mapping terms
back to their containing documents. The data you have is already
inverted.

I'd suggest uninverting it and then hand it to Solr in that format,
thus:

doc1: java
doc2: java
doc4: book
doc5: java
doc9: book
doc77: book

With that structure, you'll have in your index exactly what Solr
expects, and will be able to take advantage of the inbuilt ranking
capabilities of Lucene and Solr.

Upayavira

On Wed, Nov 28, 2012, at 10:15 AM, Floyd Wu wrote:
> Hi there,
> 
> If I have a list that is key-value pair in text filed or database table.
> How do I achieve dynamic ranking based on search term? That say when user
> search term "java" and doc1,doc2, doc5 will get higher ranking.
> 
> for example( key is search term, value is related index document unique
> key):
> ==========
> key, value
> ==========
> java, doc1,doc2,doc5
> book, doc9, doc4,doc77
> ==========
> 
> I've finished implementation using externalFileField to do ranking, but
> in
> this way, ranking is static.
> 
> Please kindly point me a way to do this.
> 
> PS: SearchComponent maybe?