Sort on "long" type field


(arien) #1

Hi all;
As per the tutorial provided in search api-sort(Elastic search guide),I am
trying to sort results according to "Size" of the file field(long type).
But as per my observation it works perfectly fine in String types fields.
if i want to apply it to "Size" field i would be doing something like this
as an example:

{ "sort" : { { "Size" : {"order" : "asc"} } }, "query" : { "term" : {
"user" : "arien" } } }

But as mentioned in the guide at the end that if one wants to apply it to
other than String type fields one must mention "type" explicitly

So i tried with following query say;

===========================================
{ "sort" : { { "Size" : {"order" : "asc" ,"type" : "long"} } }, "query" : {
"term" : { "user" : "arien" } } }

With above too i m not getting sorted results in "Size",

Please guide me if i m doing something wrong in this for which i will be
very grateful.
Thanks


(Kun Niu) #2

I don't think this will work because the column is already analyzed.

You can search for not_analyzed from this group.

You should specify the type in the column definition request instead of the search request.

From: elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] On Behalf Of arien
Sent: 2011年9月21日 15:05
To: elasticsearch@googlegroups.com
Subject: Sort on "long" type field

Hi all;

As per the tutorial provided in search api-sort(Elastic search guide),I am trying to sort results according to "Size" of the file field(long type).

But as per my observation it works perfectly fine in String types fields.

if i want to apply it to "Size" field i would be doing something like this as an example:

======================================

{ "sort" : { { "Size" : {"order" : "asc"} } }, "query" : { "term" : { "user" : "arien" } } }

===========================================

But as mentioned in the guide at the end that if one wants to apply it to other than String type fields one must mention "type" explicitly

So i tried with following query say;

===========================================

{ "sort" : { { "Size" : {"order" : "asc" ,"type" : "long"} } }, "query" : { "term" : { "user" : "arien" } } }

===========================================

With above too i m not getting sorted results in "Size",

Please guide me if i m doing something wrong in this for which i will be very grateful.

Thanks


(arien) #3

hi;
The type of the mapping i am creating for "Size" column is shown in
following sample.

"Size" : {
"type" : "long",
"fields" : {
"Size" : { "term_vector":"with_positions_offsets", "store":"yes" }
}
},

can u elaborate more on what u wanted to explain on already analyzed and
not-analyzed because i m not using any custom analysers anywhere and may be
all fields are having default analyzers applicable.

Thanks

On Wed, Sep 21, 2011 at 12:45 PM, Kun Niu haoniukun@gmail.com wrote:

I don't think this will work because the column is already analyzed.****

You can search for not_analyzed from this group.****

You should specify the type in the column definition request instead of the
search request.****


From: elasticsearch@googlegroups.com [mailto:
elasticsearch@googlegroups.com] On Behalf Of arien
Sent: 2011年9月21日 15:05
To: elasticsearch@googlegroups.com
Subject: Sort on "long" type field
**


Hi all;****

As per the tutorial provided in search api-sort(Elastic search guide),I am
trying to sort results according to "Size" of the file field(long type).**
**

But as per my observation it works perfectly fine in String types fields.*


if i want to apply it to "Size" field i would be doing something like this
as an example:****

======================================****


{ "sort" : { { "Size" : {"order" : "asc"} } }, "query" : { "term" : {
"user" : "arien" } } }****

===========================================****



But as mentioned in the guide at the end that if one wants to apply it to
other than String type fields one must mention "type" explicitly****


So i tried with following query say;****



===========================================****

{ "sort" : { { "Size" : {"order" : "asc" ,"type" : "long"} } }, "query" :
{ "term" : { "user" : "arien" } } }****

===========================================****




With above too i m not getting sorted results in "Size",****


Please guide me if i m doing something wrong in this for which i will be
very grateful.****

Thanks****


(Shay Banon) #4

You can easily sort on fields with mapping of type long (analyzed or
not_analyzed are not relevant for numeric types, just if its indexed or
not), it works. Does the Size field really is of type long? You can use the
get mapping API to check.

On Thu, Sep 22, 2011 at 7:57 AM, ajay padvi ajaypadvi@gmail.com wrote:

hi;
The type of the mapping i am creating for "Size" column is shown in
following sample.

"Size" : {
"type" : "long",
"fields" : {
"Size" : { "term_vector":"with_positions_offsets", "store":"yes" }
}
},

can u elaborate more on what u wanted to explain on already analyzed and
not-analyzed because i m not using any custom analysers anywhere and may be
all fields are having default analyzers applicable.

Thanks

On Wed, Sep 21, 2011 at 12:45 PM, Kun Niu haoniukun@gmail.com wrote:

I don't think this will work because the column is already analyzed.****

You can search for not_analyzed from this group.****

You should specify the type in the column definition request instead of
the search request.****


From: elasticsearch@googlegroups.com [mailto:
elasticsearch@googlegroups.com] On Behalf Of arien
Sent: 2011年9月21日 15:05
To: elasticsearch@googlegroups.com
Subject: Sort on "long" type field
**


Hi all;****

As per the tutorial provided in search api-sort(Elastic search guide),I am
trying to sort results according to "Size" of the file field(long type).*


But as per my observation it works perfectly fine in String types fields.


if i want to apply it to "Size" field i would be doing something like this
as an example:****

======================================****


{ "sort" : { { "Size" : {"order" : "asc"} } }, "query" : { "term" : {
"user" : "arien" } } }****

===========================================****



But as mentioned in the guide at the end that if one wants to apply it to
other than String type fields one must mention "type" explicitly****


So i tried with following query say;****



===========================================****

{ "sort" : { { "Size" : {"order" : "asc" ,"type" : "long"} } }, "query" :
{ "term" : { "user" : "arien" } } }****

===========================================****




With above too i m not getting sorted results in "Size",****


Please guide me if i m doing something wrong in this for which i will be
very grateful.****

Thanks****


(Kun Niu) #5

Yes. If you set type to long, it should work. You should verify the
setting of the column.
How did you set the type of the column, using a configuration file or
using your program?

On Thu, Sep 22, 2011 at 4:00 AM, Shay Banon kimchy@gmail.com wrote:

You can easily sort on fields with mapping of type long (analyzed or
not_analyzed are not relevant for numeric types, just if its indexed or
not), it works. Does the Size field really is of type long? You can use the
get mapping API to check.

On Thu, Sep 22, 2011 at 7:57 AM, ajay padvi ajaypadvi@gmail.com wrote:

hi;
The type of the mapping i am creating for "Size" column is shown in
following sample.

"Size" : {
"type" : "long",
"fields" : {
"Size" : { "term_vector":"with_positions_offsets", "store":"yes" }
}
},

can u elaborate more on what u wanted to explain on already analyzed and
not-analyzed because i m not using any custom analysers anywhere and may be
all fields are having default analyzers applicable.
Thanks

On Wed, Sep 21, 2011 at 12:45 PM, Kun Niu haoniukun@gmail.com wrote:

I don't think this will work because the column is already analyzed.

You can search for not_analyzed from this group.

You should specify the type in the column definition request instead of
the search request.

From: elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] On Behalf Of arien
Sent: 2011年9月21日 15:05
To: elasticsearch@googlegroups.com
Subject: Sort on "long" type field

Hi all;

As per the tutorial provided in search api-sort(Elastic search guide),I
am trying to sort results according to "Size" of the file field(long type).

But as per my observation it works perfectly fine in String types fields.

if i want to apply it to "Size" field i would be doing something like
this as an example:

======================================

{ "sort" : { { "Size" : {"order" : "asc"} } }, "query" : { "term" : {
"user" : "arien" } } }

===========================================

But as mentioned in the guide at the end that if one wants to apply it to
other than String type fields one must mention "type" explicitly

So i tried with following query say;

===========================================

{ "sort" : { { "Size" : {"order" : "asc" ,"type" : "long"} } }, "query"
: { "term" : { "user" : "arien" } } }

===========================================

With above too i m not getting sorted results in "Size",

Please guide me if i m doing something wrong in this for which i will be
very grateful.

Thanks

--
牛坤
MSN:haoniukun@hotmail.com


(system) #6