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

Exception when empty result returned with a geo sort #7450

Closed
frett27 opened this issue Aug 26, 2014 · 2 comments
Closed

Exception when empty result returned with a geo sort #7450

frett27 opened this issue Aug 26, 2014 · 2 comments
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug help wanted adoptme

Comments

@frett27
Copy link

frett27 commented Aug 26, 2014

i'm using 1.1 version of elastic search, and it result an exception if the result is empty.
the index has the location field, with correct geo_point type

i don't have a precise view of the source structure, but it seems the mapper is not found.

any help is welcome.

cheers,
Patrice

Query sent :

{
  "size": 5,
  "query": {
    "bool": {
      "should": {
        "query_string": {
          "query": "complet3:(rtpjijier*)"
        }
      }
    }
  },
  "fields": [
    "gcd_num",
    "gcd_nomrue",
    "gcd_cp",
    "depadmin",
    "locality",
    "locname",
    "postcode",
    "gcd_ville",
    "complet"
  ],
  "sort": [
    {
      "_geo_distance": {
        "location": [
          4.899999999999901,
          45.69989402483941
        ],
        "unit": "km"
      }
    }
  ]
}

Throws this exception:

    [2014-08-26 08:44:43,175][DEBUG][action.search.type       ] [El Muerto] [keyword][1], node[lGfj6zEdTy-9f8ZClTkI9Q], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@1564f3fe] lastShard [true]
    org.elasticsearch.search.SearchParseException: [keyword][1]: query[complet3:rtpjijier*],from[-1],size[5]: Parse Failure [Failed to parse source [{"size":5,"query":{"bool":{"should":{"query_string":{"query":"complet3:(rtpjijier*)"}}}},"fields":["gcd_num","gcd_nomrue","gcd_cp","depadmin","locality","locname","postcode","gcd_ville","complet"],"sort":[{"_geo_distance":{"location":[4.899999999999901,45.69989402483941],"unit":"km"}}]}]]
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:634)
        at org.elasticsearch.search.SearchService.createContext(SearchService.java:507)
        at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:480)
        at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:186)
        at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteDfs(SearchServiceTransportAction.java:168)
        at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchDfsQueryThenFetchAction.java:85)
        at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)
        at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:203)
        at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:186)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
    Caused by: org.elasticsearch.ElasticsearchIllegalArgumentException: failed to find mapper for [location] for geo distance based sort
        at org.elasticsearch.search.sort.GeoDistanceSortParser.parse(GeoDistanceSortParser.java:120)
        at org.elasticsearch.search.sort.SortParseElement.addCompoundSortField(SortParseElement.java:138)
        at org.elasticsearch.search.sort.SortParseElement.parse(SortParseElement.java:80)
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:622)
        ... 11 more
@clintongormley
Copy link
Contributor

Related to #5532

@clintongormley clintongormley added the :Analytics/Geo Indexing, search aggregations of geo points and shapes label Nov 10, 2014
@clintongormley
Copy link
Contributor

I'm unable to replicate this bug. Things seem to work as expected (as long as the location field exists in the same index):

DELETE /t 

PUT /t
{
  "mappings": {
    "t": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

PUT /t/t/1
{
  "bar": "one",
  "location": "0,0"
}

PUT /t/t/2
{
  "bar": "two"
}

Try changing bar to one | two | three:

GET _search
{
  "query": {
    "match": {
      "bar": "one"
    }
  },
  "sort": [
    {
      "_geo_distance": {
        "location": {
          "lat": 40,
          "lon": -70
        },
        "order": "asc"
      }
    }
  ]
}

I think the original cause of your exception probably came from either:

  1. searching across indices, where one index didn't include the location field (Missing geo field causes error if searching over that field #5532)
  2. having two fields called location, one of which was not a geo-point (Field resolution should be unambiguous #4081)

Closing in favour of the already open issues above. If you have more detail that points to a different bug, please feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug help wanted adoptme
Projects
None yet
Development

No branches or pull requests

2 participants