Sorting of numeric 'null' fields


(Jan Fiedler) #1

When sorting results by a numeric (integer) field I noticed that
documents with missing values are sorted as if the value would be
numeric 0. Is this intended behavior? I know that I can provide a
default value to be indexed as part of the mapping definition.
However, without such a mapping the default behavior is not to add the
field at all (this is what the doc says and what I want). What I need
from a business prospective is that documents with 'null' values for
the sort field are always at the end of the sorted result (independent
of sort order). I kind of remember this to be referred to as
'sortMissingLast' in the Lucene / SOLR community.


(Shay Banon) #2

Yes, thats the current behavior. This can be added quite easily, care to open an issue for htis?
On Friday, March 11, 2011 at 4:43 PM, Jan Fiedler wrote:

When sorting results by a numeric (integer) field I noticed that
documents with missing values are sorted as if the value would be
numeric 0. Is this intended behavior? I know that I can provide a
default value to be indexed as part of the mapping definition.
However, without such a mapping the default behavior is not to add the
field at all (this is what the doc says and what I want). What I need
from a business prospective is that documents with 'null' values for
the sort field are always at the end of the sorted result (independent
of sort order). I kind of remember this to be referred to as
'sortMissingLast' in the Lucene / SOLR community.


(Jan Fiedler) #3

Filed enhancement request: https://github.com/elasticsearch/elasticsearch/issues/772
Looking forward to it ... :wink:

On Mar 12, 9:05 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Yes, thats the current behavior. This can be added quite easily, care to open an issue for htis?

On Friday, March 11, 2011 at 4:43 PM, Jan Fiedler wrote:

When sorting results by a numeric (integer) field I noticed that
documents with missing values are sorted as if the value would be
numeric 0. Is this intended behavior? I know that I can provide a
default value to be indexed as part of the mapping definition.
However, without such a mapping the default behavior is not to add the
field at all (this is what the doc says and what I want). What I need
from a business prospective is that documents with 'null' values for
the sort field are always at the end of the sorted result (independent
of sort order). I kind of remember this to be referred to as
'sortMissingLast' in the Lucene / SOLR community.


(system) #4