lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: sort question
Date Mon, 21 May 2012 10:38:22 GMT
I'm not clear what you are asking.

Are you saying that you want keyword matching to be more important
than sorting? If that's the case, don't sort.

Or are you saying that sorting of null values isn't doing what you
want?  Use an actual value instead of null, whatever makes sense in
your application.

On a general note, if you are really trying to sort on string values
like "10%", "20%" you need to be careful - this is just a string sort
and "5%" will sort after "49%".  I'd lose the percent sign and pad the
values to a consistent length or, better, upgrade to the latest
release and use a NumericField.


On Mon, May 21, 2012 at 11:17 AM, Chaoqing Li <> wrote:
> Hi,
> I'm using Lucene2.1 to search product information, such as product name,
> description, etc.
> There is a sort on discount field, the product with discount price should
> be at the top of the result page.
> example documents:
> product1(name: aaa, description: ddd bbb, discount:null)
> product2(name: bbb, description: ddd bbb, discount:10%)
> product3(name: ccc, description: ddd bbb, discount:20%)
> We have a sort field on discount, so the order of search result by keyword
> "ddd" is product3 product2 product1.
> but we want the products which name include the keyword should be the top
> of the result even though they has no discount.
> so if search by "bbb",
> because the name of product2 include "bbb", the order should be product2
> product3 product1.
> Any idea to implement it?
> Thanks,

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

View raw message