Pazhaniyappan
(Pazhaniyappan Muthukkaruppan)
May 11, 2022, 5:53am
1
Mapping for the index:
PUT /my_locations
{
"mappings": {
"properties": {
"pin": {
"type":"nested",
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
}
Search query:
GET /my_locations/_search
{
"sort": [
"_score",
{
"_geo_distance": {
"nested_path": "pin",
"query": {
"pin.location": {
"lat":41.12,
"lon":-71.34
},
"unit": "mi",
"order": "asc"
}
}
}
]
}
Response:
{
"error" : {
"root_cause" : [
{
"type" : "parse_exception",
"reason" : "unsupported symbol [i] in geohash [pin]"
}
],
"type" : "parse_exception",
"reason" : "unsupported symbol [i] in geohash [pin]",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "unsupported symbol [i] in geohash [pin]"
}
},
"status" : 400
}
Elasticsearch and Kibana version: 8.1.3
Can you please suggest a solution for this error?
RabBit_BR
(andre.coelho)
May 11, 2022, 1:10pm
2
Hi!!
What the reason for type to be nested?
Pazhaniyappan:
"type":"nested",
This works:
GET /my_locations/_search
{
"sort": [
"_score",
{
"_geo_distance": {
"pin.location": {
"lat": 40,
"lon": -70
},
"unit": "mi",
"order": "asc"
}
}
]
}
I performed the example in this doc and get successful.
spinscale
(Alexander Reelsen)
May 11, 2022, 1:39pm
3
Wild guess from a quick read: Is is possible, that you need to use a geo distance query within the nested sort? See Sort search results | Elasticsearch Guide [8.2] | Elastic where a filter is used as an example.
Pazhaniyappan
(Pazhaniyappan Muthukkaruppan)
May 13, 2022, 9:57am
4
Hi @RabBit_BR
Thank you for your response.
Basically, I have multiple elements inside pin (XML data) that I convert to JSON and index in Elasticsearch. For example,
<root>
<pin>
<location>621215</location>
</pin>
<pin>
<location>621214</location>
</pin>
</root>
So, I have chosen the type of pin nested. Your query for my index reports error in my environment. Please find the error below.
{
"error" : {
"root_cause" : [
{
"type" : "query_shard_exception",
"reason" : "it is mandatory to set the [nested] context on the nested sort field: [pin.location].",
"index_uuid" : "-2-ExiOnRyy6ygTPJCIRrQ",
"index" : "my_locations"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "my_locations",
"node" : "XDpHvG5tSEuy-83Iwfu4EA",
"reason" : {
"type" : "query_shard_exception",
"reason" : "it is mandatory to set the [nested] context on the nested sort field: [pin.location].",
"index_uuid" : "-2-ExiOnRyy6ygTPJCIRrQ",
"index" : "my_locations"
}
}
]
},
"status" : 400
}
Please let me know if you need some more details.
Pazhaniyappan
(Pazhaniyappan Muthukkaruppan)
May 13, 2022, 10:02am
5
Hi @spinscale
Thank you for your response. Geo distance seems not working within the nested sort.
Would you please give some samples?
RabBit_BR
(andre.coelho)
May 13, 2022, 2:52pm
6
When you convert the data are you using a geoIP processor?
Pazhaniyappan
(Pazhaniyappan Muthukkaruppan)
May 16, 2022, 10:20am
7
@RabBit_BR - having a mapping file contains postal code to lat lon values.
system
(system)
Closed
June 17, 2022, 5:14am
9
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.