lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Monsur Hossain" <>
Subject Re: Sorting & SQL-Database
Date Mon, 03 Jul 2006 21:26:17 GMT
On 6/30/06, Dominik Bruhn <> wrote:
> SELECT id,addfield FROM table WHERE id IN ([LUCENERESULT]);
> Where LUCENERESULT is like 2,3,19,3,5.
> This works fine but got one problem: The Search-Result of Lucene is order by
> relevance and so the id-list is also sorted by relevance. But the result of
> the SQL-Query is sorted by the id which destroys the relevance-sorting.
> Does anybody know a work-arround?

We have the same issue and solve this through code.  As you're
generating the list of IDs for the SQL query, also generate a hash
that maps the ID to its position.  When reading back the data from the
database, read the position hash, and insert the item into the
appropriate position in an array.  Yeah, you're doing the sorting
yourself, but in our case, we're only returning 10 items per page, so
its not a huge performance hit.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message