You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by madhav bahuguna <ma...@gmail.com> on 2014/07/15 09:24:13 UTC

Sort not working in solr

Iam trying to sort my records but the result i get is not correct
My url query--
http://localhost:8983/solr/select/?&q=*:*&fl=business_point&sort=business_point+desc

Iam trying to sort my records by business_points but the result i get is in
like this
9
8
7
6
5
45
4
4
10
1

Whys am i getting my results in the wrong order
my schema looks like this
<field name="business_point" type="text_general" indexed="true"
stored="true" required="false" multiValued="false"/>

-- 
Regards
Madhav Bahuguna

Re: Sort not working in solr

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
That's always what happens (not just in Solr) when you store numbers
as text. You could store them as text-sortable numbers with leading
zeros (e.g. 04 vs. 45), but then what happens when you hit a 100?
Alternatively, if that field has only numbers, index it as a numeric
type. Make sure to use one of the new types (see recent Solr example),
not the old type that also has the same problem.

Regards,
  Alex.
Personal: http://www.outerthoughts.com/ and @arafalov
Solr resources: http://www.solr-start.com/ and @solrstart
Solr popularizers community: https://www.linkedin.com/groups?gid=6713853


On Tue, Jul 15, 2014 at 2:24 PM, madhav bahuguna
<ma...@gmail.com> wrote:
> Iam trying to sort my records but the result i get is not correct
> My url query--
> http://localhost:8983/solr/select/?&q=*:*&fl=business_point&sort=business_point+desc
>
> Iam trying to sort my records by business_points but the result i get is in
> like this
> 9
> 8
> 7
> 6
> 5
> 45
> 4
> 4
> 10
> 1
>
> Whys am i getting my results in the wrong order
> my schema looks like this
> <field name="business_point" type="text_general" indexed="true"
> stored="true" required="false" multiValued="false"/>
>
> --
> Regards
> Madhav Bahuguna

Re: Sort not working in solr

Posted by Apoorva Gaurav <ap...@myntra.com>.
In fact its better using TrieIntField instead of IntField.
http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201301.mbox/%3CCAB_8Yd9Yp259kK4ciYbbPrJCPWQp6VD7YVrTJR1eUBeW_kYtWw@mail.gmail.com%3E
http://stackoverflow.com/questions/13372323/what-is-the-correct-solr-fieldtype-to-use-for-sorting-integer-values


On Tue, Jul 15, 2014 at 1:09 PM, スガヌマヨシカズ <su...@gmail.com> wrote:

> i think type="text_general" make it charactered-sort for numbers.
>
> How about make it as type="int" or type="long" instead of "text_general"?
>
> ----
> <field name="business_point" type="text_general" indexed="true"
> stored="true" required="false" multiValued="false"/>
> ----
>
> Regards,
> suganuma
>
>
> 2014-07-15 16:24 GMT+09:00 madhav bahuguna <ma...@gmail.com>:
>
> > Iam trying to sort my records but the result i get is not correct
> > My url query--
> >
> >
> http://localhost:8983/solr/select/?&q=*:*&fl=business_point&sort=business_point+desc
> >
> > Iam trying to sort my records by business_points but the result i get is
> in
> > like this
> > 9
> > 8
> > 7
> > 6
> > 5
> > 45
> > 4
> > 4
> > 10
> > 1
> >
> > Whys am i getting my results in the wrong order
> > my schema looks like this
> > <field name="business_point" type="text_general" indexed="true"
> > stored="true" required="false" multiValued="false"/>
> >
> > --
> > Regards
> > Madhav Bahuguna
> >
>



-- 
Thanks & Regards,
Apoorva

Re: Sort not working in solr

Posted by スガヌマヨシカズ <su...@gmail.com>.
i think type="text_general" make it charactered-sort for numbers.

How about make it as type="int" or type="long" instead of "text_general"?

----
<field name="business_point" type="text_general" indexed="true"
stored="true" required="false" multiValued="false"/>
----

Regards,
suganuma


2014-07-15 16:24 GMT+09:00 madhav bahuguna <ma...@gmail.com>:

> Iam trying to sort my records but the result i get is not correct
> My url query--
>
> http://localhost:8983/solr/select/?&q=*:*&fl=business_point&sort=business_point+desc
>
> Iam trying to sort my records by business_points but the result i get is in
> like this
> 9
> 8
> 7
> 6
> 5
> 45
> 4
> 4
> 10
> 1
>
> Whys am i getting my results in the wrong order
> my schema looks like this
> <field name="business_point" type="text_general" indexed="true"
> stored="true" required="false" multiValued="false"/>
>
> --
> Regards
> Madhav Bahuguna
>