lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Custom sorting!
Date Fri, 05 Jun 2009 15:21:02 GMT
Hi


One would indeed expect that JAHN would come before JOHNSON.  I can't
spot anything wrong with your code but it isn't all there and the
problem could lie with something not shown.

Why don't you cut it down to a nice short self-contained program or
test case and if that doesn't help you find the problem yourself, post
it here.  But keep it short and simple and with no external
references/dependencies.


--
Ian.


On Fri, Jun 5, 2009 at 3:02 PM, vanshi<nilu.thakur@gmail.com> wrote:
>
> Can somebody take a look in why I'm not getting the correct alphabetical
> order?
>
> I changed last_name field to be 'UN_TOKENIZED' and sorting on only last
> name, then network status. But with last name as 'J' in query, I am getting
> results like:
>
> JACOBSON
> JOHNSON
> JAHN
>
> I would expect 'JAHN' to come before 'johnson'.
>
> can somebody suggest wht's going wrong here.
>
> Vanshi
>
>
> vanshi wrote:
>>
>> I am doing custom sorting within lucene using overloaded
>> searcher.search(query, sort). First precedence is to sort based on 'last
>> name' and then on 'network status', where 'INN' is better than 'OUT'.
>>
>> Fields are stored in the indexes like this:
>>
>> FIRST_NAME(Field.Store.NO, Field.Index.NO_NORMS)
>> LAST_NAME_EXACT(Field.Store.NO, Field.Index.NO_NORMS)
>>
>> And analyzer used is 'keyword analyzer' on these fields. And the fields
>> are sorted with following lines.
>>
>> ArrayList<SortField> sorts = new ArrayList<SortField>();
>> sorts.add(new SortField("LAST_NAME_EXACT"));
>> sorts.add(new SortField(ProviderFieldInfo.NETWORK.toString(),
>> networkComparatorSource));
>> super.setSort(sorts.toArray(new SortField[sorts.size()]));
>>
>> Now, with the above line my expectation is to see 'last name' sorted
>> alphabatically and then if two 'last names' are same then 'network
>> status(INN/OUT)' must get precedence and if both 'network status' and
>> 'last name' are same then socre will decide the order. Is this expectation
>> wrong??
>>
>> The result I'm getting is in this order: The query used is a prefix query,
>> where 'last name' entered is 'john' and first name is 'p'.
>>
>> JOHNSON, PETER A      INN
>> JOHNSON, PETER B              INN
>> JOHNSON, PEGGY A      OUT
>> JOHNSON, PHILLIP W    INN
>> JOHNSON-STUHR, PAMELA J       OUT
>> JOHN, P G             INN
>> JOHNSON, PAUL G               INN
>> JOHNSON, PETER R              INN
>>
>> Can somebody take alook and see what should be done to get expected
>> results?
>>
>> Thanks,
>> Vanshi
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Custom-sorting%21-tp23876641p23888815.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message