How to sort value that numeric mix alpha

2014-06-29 Thread rachun
Dear all,

Could anybody suggest me how to sort the field that has numeric mix with
alpha.
In my case I have field name 'product_id' which contain value  like
C1,C2,C3,C4,C9,C12,C23,C50

when I try to sort (DESC) it return wrong result something like this
C9,C50,C4,C3,C23,C2,C12,C1

As you see I have 'C' for prefix.

So, In my Schema.xml I have tried this...

   fieldType name=alphaOnlySort class=solr.TextField
sortMissingLast=true omitNorms=true
  analyzer
tokenizer class=solr.KeywordTokenizerFactory/
filter class=solr.LowerCaseFilterFactory /
filter class=solr.TrimFilterFactory /
filter class=solr.PatternReplaceFilterFactory
pattern=([^a-z]) replacement= replace=all
/
  /analyzer
/fieldType 

field name=pid_sort type=alphaOnlySort indexed=true stored=true /

copyField source=product_id dest=pid_sort/

but it didn't work. How to deal with this?

Thank you very much,
Chun.







--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-sort-value-that-numeric-mix-alpha-tp4144615.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: How to sort value that numeric mix alpha

2014-06-29 Thread IJ
Try indexing your data as follows:

C01,C02,C03,C04,C09,C12,C23,C50
 instead of 

C1,C2,C3,C4,C9,C12,C23,C50

and the sort order would work correctly.

BTW, what you are describing as an issue is NOT unique to Solr. The same
happens on regular Databases as well. Google up how database type systems
perform alphanumeric sorts - and you'll know why.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-sort-value-that-numeric-mix-alpha-tp4144615p4144616.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: How to sort value that numeric mix alpha

2014-06-29 Thread Jack Krupansky
I think you wanted to remove letters, but your pattern removes NON-letters - 
that's what the ^ does, negation.


So, try: =[a-z].

You can also get rid of the lower case filter and just use [a-zA-Z].

-- Jack Krupansky

-Original Message- 
From: rachun

Sent: Sunday, June 29, 2014 3:19 AM
To: solr-user@lucene.apache.org
Subject: How to sort value that numeric mix alpha

Dear all,

Could anybody suggest me how to sort the field that has numeric mix with
alpha.
In my case I have field name 'product_id' which contain value  like
C1,C2,C3,C4,C9,C12,C23,C50

when I try to sort (DESC) it return wrong result something like this
C9,C50,C4,C3,C23,C2,C12,C1

As you see I have 'C' for prefix.

So, In my Schema.xml I have tried this...

  fieldType name=alphaOnlySort class=solr.TextField
sortMissingLast=true omitNorms=true
 analyzer
   tokenizer class=solr.KeywordTokenizerFactory/
   filter class=solr.LowerCaseFilterFactory /
   filter class=solr.TrimFilterFactory /
   filter class=solr.PatternReplaceFilterFactory
   pattern=([^a-z]) replacement= replace=all
   /
 /analyzer
   /fieldType

field name=pid_sort type=alphaOnlySort indexed=true stored=true /

copyField source=product_id dest=pid_sort/

but it didn't work. How to deal with this?

Thank you very much,
Chun.







--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-sort-value-that-numeric-mix-alpha-tp4144615.html
Sent from the Solr - User mailing list archive at Nabble.com. 



Re: How to sort value that numeric mix alpha

2014-06-29 Thread rachun
Thank you for both of you I finally re-index data and   remove 'C' and index
only numeric. So, that the way I fix my problem.

Best,
Chun.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-sort-value-that-numeric-mix-alpha-tp4144615p4144693.html
Sent from the Solr - User mailing list archive at Nabble.com.