Sort on field with array value

Hi all.

In out data model, the uses could define fields with mutliple values, in
this example data_myrelated.
The values are stored in an array, like this:

{
"took" : 100,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "cms",
"_type" : "content",
"_id" : "101",
"_score" : 1.0,
"fields" : {
"categorykey" : "9.0",
"orderby_contenttype" : "article",
"categorykey_numeric" : 9.0,
"status" : "2",
"status_numeric" : 2.0,
"contenttype" : "article",
"orderby_data_myrelated" : [ "
\u0001@\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
" \u0001@\u0011\u0000\u0000\u0000\u0000\u0000\u0000\u0000" ],
"data_myrelated_numeric" : [ 3.0, 9.0 ]
}
} ]
}
}

(The orderby_data_myrelated is stored like this to enable correct sorting
of number values in fields where we also could get text)


{
"from" : 0,
"size" : 10,
"query" : {
"match_all" : {
}
},
"sort" : [ {
"orderby_data_myrelated" : {
"order" : "asc"
}
} ]
}

This query now yields no results, is this expected behaviour?

greetings

Runar Myklebust

You can't sort on a multi valued field, you should get a failure in your
search...

On Wed, Jan 4, 2012 at 1:26 PM, Runar Myklebust runar@myklebust.me wrote:

Hi all.

In out data model, the uses could define fields with mutliple values, in
this example data_myrelated.
The values are stored in an array, like this:

{
"took" : 100,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "cms",
"_type" : "content",
"_id" : "101",
"_score" : 1.0,
"fields" : {
"categorykey" : "9.0",
"orderby_contenttype" : "article",
"categorykey_numeric" : 9.0,
"status" : "2",
"status_numeric" : 2.0,
"contenttype" : "article",
"orderby_data_myrelated" : [ " \u0001@\u0004\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
" \u0001@\u0011\u0000\u0000\u0000\u0000\u0000\u0000\u0000" ],
"data_myrelated_numeric" : [ 3.0, 9.0 ]
}
} ]
}
}

(The orderby_data_myrelated is stored like this to enable correct sorting
of number values in fields where we also could get text)


{
"from" : 0,
"size" : 10,
"query" : {
"match_all" : {
}
},
"sort" : [ {
"orderby_data_myrelated" : {
"order" : "asc"
}
} ]
}

This query now yields no results, is this expected behaviour?

greetings

Runar Myklebust