Sorting across multiple types

I'm currently using elastic search with two types of entities being
indexed. Both entities have a field called "name". I'm issuing a
query with a sort on "name" (actually using "nameSort" which is non-
analyzed) and the results are returning sorted correctly within each
type, but not universally across the two types. Is there any way to
get the results to return sorted completely across the two types?

You could use a custom sort script, like here:
http://elasticsearch-users.115913.n3.nabble.com/Native-Script-Help-td2980754.html#a2981370
but that might impact your performance.

On Sep 19, 1:37 pm, Chris Baxter cbax...@gmail.com wrote:

I'm currently using Elasticsearch with two types of entities being
indexed. Both entities have a field called "name". I'm issuing a
query with a sort on "name" (actually using "nameSort" which is non-
analyzed) and the results are returning sorted correctly within each
type, but not universally across the two types. Is there any way to
get the results to return sorted completely across the two types?

So I'm guessing by your response that this is not just supported out
of the box.

On Sep 19, 9:17 am, davrob2 davirobe...@gmail.com wrote:

You could use a custom sort script, like here:http://elasticsearch-users.115913.n3.nabble.com/Native-Script-Help-td...
but that might impact your performance.

On Sep 19, 1:37 pm, Chris Baxter cbax...@gmail.com wrote:

I'm currently using Elasticsearch with two types of entities being
indexed. Both entities have a field called "name". I'm issuing a
query with a sort on "name" (actually using "nameSort" which is non-
analyzed) and the results are returning sorted correctly within each
type, but not universally across the two types. Is there any way to
get the results to return sorted completely across the two types?

This is supported, you can sort across types on the same field. (internally,
different types ends up being indexed as documents in the same Lucene
index). Can you gist a sample for a failure, including some data setup? (
Elasticsearch Platform — Find real-time answers at scale | Elastic).

On Mon, Sep 19, 2011 at 4:54 PM, Chris Baxter cbax007@gmail.com wrote:

So I'm guessing by your response that this is not just supported out
of the box.

On Sep 19, 9:17 am, davrob2 davirobe...@gmail.com wrote:

You could use a custom sort script, like here:
http://elasticsearch-users.115913.n3.nabble.com/Native-Script-Help-td...
but that might impact your performance.

On Sep 19, 1:37 pm, Chris Baxter cbax...@gmail.com wrote:

I'm currently using Elasticsearch with two types of entities being
indexed. Both entities have a field called "name". I'm issuing a
query with a sort on "name" (actually using "nameSort" which is non-
analyzed) and the results are returning sorted correctly within each
type, but not universally across the two types. Is there any way to
get the results to return sorted completely across the two types?

I figured out my issue. I had mixed case in my names across the two
different types, with one of the types always being all lower.
Because the field I am sorting on is not analyzed (only way to
properly sort on it), the case was not being normalized when the
entity was indexed. I fixed this in my app code to lowercase this
field specifically before indexing and that fixed the problem. Thanks
for letting me know that this should have worked as that let me know
that the problem was probably on my side.

On Sep 20, 4:20 am, Shay Banon kim...@gmail.com wrote:

This is supported, you can sort across types on the same field. (internally,
different types ends up being indexed as documents in the same Lucene
index). Can you gist a sample for a failure, including some data setup? (Elasticsearch Platform — Find real-time answers at scale | Elastic).

On Mon, Sep 19, 2011 at 4:54 PM, Chris Baxter cbax...@gmail.com wrote:

So I'm guessing by your response that this is not just supported out
of the box.

On Sep 19, 9:17 am, davrob2 davirobe...@gmail.com wrote:

You could use a custom sort script, like here:
http://elasticsearch-users.115913.n3.nabble.com/Native-Script-Help-td...
but that might impact your performance.

On Sep 19, 1:37 pm, Chris Baxter cbax...@gmail.com wrote:

I'm currently using Elasticsearch with two types of entities being
indexed. Both entities have a field called "name". I'm issuing a
query with a sort on "name" (actually using "nameSort" which is non-
analyzed) and the results are returning sorted correctly within each
type, but not universally across the two types. Is there any way to
get the results to return sorted completely across the two types?