Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

sort question

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


lichaoqing at gmail

May 21, 2012, 3:17 AM

Post #1 of 4 (310 views)
Permalink
sort question

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,


ian.lea at gmail

May 21, 2012, 3:38 AM

Post #2 of 4 (303 views)
Permalink
Re: sort question [In reply to]

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.


--
Ian.


On Mon, May 21, 2012 at 11:17 AM, Chaoqing Li <lichaoqing [at] gmail> 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: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


lichaoqing at gmail

May 21, 2012, 7:04 PM

Post #3 of 4 (297 views)
Permalink
Re: sort question [In reply to]

Sorry for the confusion.

It's the first one you mentioned below.
We have a sort on discount field, and if the keyword match the name field,
we need it's important than sorting.
if don't sort, how can we implement this request? I'm stuck here.

and the discount has been convert to number already, thanks for your
information.

Thanks,
CQ

2012/5/21 Ian Lea <ian.lea [at] gmail>

> 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.
>
>
> --
> Ian.
>
>
> On Mon, May 21, 2012 at 11:17 AM, Chaoqing Li <lichaoqing [at] gmail>
> 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: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>


ian.lea at gmail

May 22, 2012, 1:40 AM

Post #4 of 4 (295 views)
Permalink
Re: sort question [In reply to]

Sorting beats scoring - that's what it's for. If you want scoring to
win, don't sort. If you want particular searches to score higher than
others, look at boosting. If you want to mix and match you can do
that too: run multiple searches, with or without sorting, your choice,
and merge the resultant hit lists in whatever order makes sense to
you.


--
Ian.

On Tue, May 22, 2012 at 3:04 AM, Chaoqing Li <lichaoqing [at] gmail> wrote:
> Sorry for the confusion.
>
> It's the first one you mentioned below.
> We have a sort on discount field, and if the keyword match the name field,
> we need it's important than sorting.
> if don't sort, how can we implement this request? I'm stuck here.
>
> and the discount has been convert to number already, thanks for your
> information.
>
> Thanks,
> CQ
>
> 2012/5/21 Ian Lea <ian.lea [at] gmail>
>
>> 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.
>>
>>
>> --
>> Ian.
>>
>>
>> On Mon, May 21, 2012 at 11:17 AM, Chaoqing Li <lichaoqing [at] gmail>
>> 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: java-user-unsubscribe [at] lucene
>> For additional commands, e-mail: java-user-help [at] lucene
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.