Elasticsearch sort on combined fields

Hi all,

I'm having troubles with sorting based on a combination of fields. For
instance, i have a document:

{ "name": "blah",
"age": 1,
"id": "132456"}

I need to get all documents sorted by the combination of name and id. I
don't want sort based first on name and then on id... I really need the
combination of both!

Here:
http://www.elasticsearch.org/guide/reference/api/search/sort.html

Is referred sorting based on scripting, but is not working.

Can anyone help?

Thanks,

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Did you specify the type? If I am not mistaken, something like this should
work :

{
"query": {
"match_all": {}
},
"sort": {
"_script": {
"script": "doc['name'].value + doc['id'].value",
"type": "string",
"order": "asc"
}
}
}

But I think that kind of sort will be quite heavy. If I had to do this, I
would index another field (not analyzed) that would be that combination,
and I'd sort on it instead. Should be more efficient.

Le mardi 26 mars 2013 12:51:37 UTC+1, Vania S. a écrit :

Hi all,

I'm having troubles with sorting based on a combination of fields. For
instance, i have a document:

{ "name": "blah",
"age": 1,
"id": "132456"}

I need to get all documents sorted by the combination of name and id. I
don't want sort based first on name and then on id... I really need the
combination of both!

Here:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Is referred sorting based on scripting, but is not working.

Can anyone help?

Thanks,

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.