Now (after upgrading to 8.6) it plum doesn't work. Can some one help, please. It is so strange looking at 15 lines of code and honestly going over every variation imaginable to not find a solution. Here is my latest attempt:
the error log is complaining about location not being a field, and other odds and ends like; Caused by:
illegal_argument_exception: unsupported symbol [i] in geohash [si]
Root causes:
parse_exception: unsupported symbol [i] in geohash [si]
I don't understand. argh. Sorry to just dump code here, but mappings from firestore are fixed. And now I need to query that data into a format that is understood by client, correct?
Do I need to nest and double nest properties and pin fields in the mappings in my ref?
The issue here is that geo_distance sort does not support a distance field and it is treating it as the field containing the point to be sorted. Then there are two errors possible:
It cannot parse the content of the field as a point, then you get errors like the one above:
illegal_argument_exception: unsupported symbol [i] in geohash [si]
Root causes:
parse_exception: unsupported symbol [i] in geohash [si]
If it parses the content on distance, then it fails when finding the location field as it has already set the coordinate value:
Root causes:
parsing_exception: Trying to reset fieldName to [location], already set to [distance].
To fix it, please remove the distance field as it is not needed for sorting. Feel free to open an issue to improve the error messages as I think we should provide better guidance here.
Root causes:
query_shard_exception: failed to find geo field [location]
Root causes:
query_shard_exception: failed to find geo field [location]
at SniffingTransport.request (node_modules/@elastic/transport/lib/Transport.js:479:27)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.SearchApi [as search] (node_modules/@elastic/elasticsearch/lib/api/api/search.js:66:12)
The error is clear on what is going on, your location field is not a geo field, something is not working as expected between your mappings and the data you are ingesting. You said that from the mappings API you see the following:
location is being mapped as two floats, something is failing there and the value is not mapped to a geo_point. It is very strange the _latitude and _longitude names, that seems wrong. Could you share the format of one of the geo_point you are ingesting?
I thought that was the desired format. But good to know!
When i do this:
// Transform data as we receive it from firestore
transform: (data, parent) => ({
...data,
// location: new GeoPoint(data.location._latitude,data.location._longitude)
// latitude: `${data.location._latitude}`,
// longitude: `${data.location._longitude}`
location:`${data.location._latitude},${data.location._longitude}`
})
query_shard_exception: Field [location] is of unsupported type [text] for [geo_distance] query
Root causes:
query_shard_exception: Field [location] is of unsupported type [text] for [geo_distance] query
at SniffingTransport.request (node_modules/@elastic/transport/lib/Transport.js:479:27)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.SearchApi [as search] (node_modules/@elastic/elasticsearch/lib/api/api/search.js:66:12)
This is what I get in console with filter commented out, and this as well ( //location:${data.location._latitude},${data.location._longitude}) commented out in transform:
location: "32.04935700000001,34.75835500000001"
and back to the way I had it originally returns this:
I am not familiar with the way you are doing things but I would expect this to work:
// Transform data as we receive it from firestore
transform: (data, parent) => ({
...data,
// location: new GeoPoint(data.location._latitude,data.location._longitude)
// latitude: `${data.location._latitude}`,
// longitude: `${data.location._longitude}`
location:`${data.location._latitude},${data.location._longitude}`
})
If you have created the mapping or an index template before ingesting data . Are you using an explicit mapping or an index template? Has this been execute before indexing data?
mmh, I see that repository has not been updated in a while and predates the release of Elasticsearch 8.0.0. More over in the packages it seems to have been tested with Elasticsearch 7.8.0:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.