You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Kev Kilroy <ke...@hotmail.com> on 2010/03/12 11:47:21 UTC

Sorting case insensitive wildcard query (with highlight)

Hi,

I'm using Lucene 2.4.1 with Hibernate Search 3.1.1. I have objects in the index, for each field I index as follows:

@Fields( value = {
        @Field(index = Index.TOKENIZED, store = Store.YES),
        @Field(name = "name_forSort", index = Index.UN_TOKENIZED, store = Store.NO),
    }) 

Therefore, I can search on the 1st field, & sort on the second field. This works fine, however, the sorting results are case sensitive.

So, for example my results come back as:

A
B
C
a

But I would like 

a
A
B
C

If I lowercase everything when I create the index, I do indeed get the results back as expected, however, when I search, the (highlighted) results come back in lower case.

For example: if I search for: d Or D (note I am using wildcard queries (d*)

I get:

dorcan road, 

whereas, when I just list the results it comes back as Dorcan Road (which is what I want).

Can anybody provide an example of how I can sort case insensitively?

Thanks in advance,

Kevin.

 		 	   		  
_________________________________________________________________
Tell us your greatest, weirdest and funniest Hotmail stories
http://clk.atdmt.com/UKM/go/195013117/direct/01/

Re: Sorting case insensitive wildcard query (with highlight)

Posted by Ian Lea <ia...@gmail.com>.
Can you just lowercase a dedicated sort field and leave the others alone.


--
Ian.


On Fri, Mar 12, 2010 at 10:47 AM, Kev Kilroy <ke...@hotmail.com> wrote:
>
> Hi,
>
> I'm using Lucene 2.4.1 with Hibernate Search 3.1.1. I have objects in the index, for each field I index as follows:
>
> @Fields( value = {
>        @Field(index = Index.TOKENIZED, store = Store.YES),
>        @Field(name = "name_forSort", index = Index.UN_TOKENIZED, store = Store.NO),
>    })
>
> Therefore, I can search on the 1st field, & sort on the second field. This works fine, however, the sorting results are case sensitive.
>
> So, for example my results come back as:
>
> A
> B
> C
> a
>
> But I would like
>
> a
> A
> B
> C
>
> If I lowercase everything when I create the index, I do indeed get the results back as expected, however, when I search, the (highlighted) results come back in lower case.
>
> For example: if I search for: d Or D (note I am using wildcard queries (d*)
>
> I get:
>
> dorcan road,
>
> whereas, when I just list the results it comes back as Dorcan Road (which is what I want).
>
> Can anybody provide an example of how I can sort case insensitively?
>
> Thanks in advance,
>
> Kevin.
>
>
> _________________________________________________________________
> Tell us your greatest, weirdest and funniest Hotmail stories
> http://clk.atdmt.com/UKM/go/195013117/direct/01/

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