Skip to content

[BUG] NullPointerException in _geo_distance sort #18420

@janschwarz

Description

@janschwarz

Describe the bug

all shards failed, root_cause: [{null_pointer_exception Cannot invoke "String.endsWith(String)" because "field" is null 

This occurs on Opensearch 3.0 with a geo_point field while sorting by distance.

"location_point": {
    "type": "geo_point"
}

Changing unit from "km" to "m" fixed it on some requests but failed again when changing sort order from "asc" to "desc"

Related component

Search

To Reproduce

  1. Have a search index with geo_point field
  2. Sort by _geo_distance
{
  "query": { "match_all": {} },
  "sort": [ { "_geo_distance": { "location_point": [9.227400, 49.189800], "order": "desc", "unit": "km", "distance_type": "arc", "mode": "min", "ignore_unmapped": true } } ],
  "size": 10
}
  1. Get an Exception all shards failed, root_cause: [{null_pointer_exception Cannot invoke "String.endsWith(String)" because "field" is null 

Expected behavior

Sorting works like in Opensearch 2.18

Additional Details

Plugins
Basic docker image:
Image with Bug: opensearchproject/opensearch:latest
Working image: opensearchproject/opensearch:2.18.0

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SearchSearch query, autocomplete ...etcbugSomething isn't working

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions