Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting by unmapped nested field #33644

Closed
marian-margeta opened this issue Sep 12, 2018 · 2 comments · Fixed by #42451
Closed

Sorting by unmapped nested field #33644

marian-margeta opened this issue Sep 12, 2018 · 2 comments · Fixed by #42451
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@marian-margeta
Copy link

marian-margeta commented Sep 12, 2018

Elasticsearch version (bin/elasticsearch --version): 6.4.0

Plugins installed: []

JVM version (java -version): 1.8.0_171

OS version (uname -a if on a Unix-like system): Windows 10

Description of the problem including expected versus actual behavior:

Field unmapped_type in sort section inside query doesn't work properly in case of nested properties. If I query for the data sorted by non-existing (unmapped) nested field I get query_shard_exception. The behavior I expect is to sort the data without nested field by a default value of a type specified in unmapped_type field. It would be consistent with current behavior for non-nested fields.

Steps to reproduce:

Let's say I have 2 indices (One with nested field and one without):

PUT index-nested 
{
  "mappings": {
    "doc": {
      "properties": {
        "notNestedField": {
          "type": "keyword"
        },
        "Nested": {
          "type": "nested",
          "properties": {
            "nestedField": {
              "type": "keyword"
            }
          }
        }
      }
    }
  }
}

PUT index-not-nested
{
  "mappings": {
    "doc": {
      "properties": {
        "notNestedField": {
          "type": "keyword"
        }
      }
    }
  }
}

The query for sorted data from both indices:

GET index-nested,index-not-nested/_search
{
  "sort": [
    {
      "Nested.nestedField": {
        "unmapped_type" : "keyword",
        "nested": {
          "path": "Nested"
        }, 
        "order": "desc"
      }
    }
  ]
}

Only data from index-nested are returned, all shards belonging to indices without nested field are failing:

...
"failures": [
      {
        "shard": 0,
        "index": "index-not-nested",
        "node": "w8_R6Fg8TLGsKq7zCRAXKg",
        "reason": {
          "type": "query_shard_exception",
          "reason": "[nested] failed to find nested object under path [Nested]",
          "index_uuid": "1D0UTBwaRHmnG2TC6PJZdg",
          "index": "index-not-nested"
        }
      }
    ]
...
@colings86 colings86 added the :Search/Search Search-related issues that do not fall into other categories label Sep 13, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@matriv matriv self-assigned this May 23, 2019
matriv added a commit to matriv/elasticsearch that referenced this issue May 23, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: elastic#33644
matriv added a commit that referenced this issue May 24, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: #33644
matriv added a commit that referenced this issue May 24, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: #33644

(cherry picked from commit 631142d)
matriv added a commit that referenced this issue May 24, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: #33644

(cherry picked from commit 631142d)
matriv added a commit that referenced this issue May 24, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: #33644

(cherry picked from commit 631142d)
matriv added a commit that referenced this issue May 24, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: #33644

(cherry picked from commit 631142d)
@matriv
Copy link
Contributor

matriv commented May 24, 2019

Backported to 7.x with 523b5bf
to 7.2 with be513ce
to 7.1 with a57d85b
to 6.8 with ed7e1f9

gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this issue May 27, 2019
Previously sorting on a missing nested field would fail with an
Exception:
`[nested_field] failed to find nested object under path [nested_path]`
despite `unmapped_type` being set on the query.

Fixes: elastic#33644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants