Field name collisions when sorting

(Daniel Chang) #1

I am having a sorting issue where the documents returned are not respecting my sort criteria.
I am using Elasticsearch version 1.4.4

I have a field project.primary_site that is defined on two document types. In one (foobar-centric) project is defined as nested in the mappings, in the second one (donor-centric) project is just a regular object.

Doing a sort on donor-centric fails and it looked like the sort key is null.

  "sort": [
      "project.primary_site": {
        "order": "asc"

The gist below should illustrate this sorting problem, if I comment out the foobar-centric related curls, the sort works.

I am wondering if I am running into the Type Gotchas documented here

If so, is the solution to just fully qualify the field names with the document type? i.e., instead of project.primary_site use donor-centric.project.primary_site and foobar-centric.project.primary_site?


(Adrien Grand) #2

Indeed this is due to your types being mapped differently. Specifying the type name might work, but it would be much better to use different field names or different indices to avoid this issue.

(system) #3