yeziblo
(yeziblo)
May 11, 2022, 9:58am
1
Hi everyone.
I just set a search template like:
POST _scripts/geoshape_search
{
"script": {
"lang": "mustache",
"source": {
"query": {
"geo_shape": {
"geo_json": {
"shape": {
"type": "point",
"coordinates": [
"{{longitude}}",
"{{latitude}}"
]
},
"relation": "intersects"
}
}
}
}
}
}
But when I use template like:
GET _search/template
{
"id": "geoshape_search",
"params": {
"longitude": -121.77777,
"latitude": 37.33333
}
}
It fails:
{
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "geo coordinates must be numbers"
}
],
"type": "parse_exception",
"reason": "geo coordinates must be numbers"
},
"status": 400
}
Any suggestion would be helpful!
spinscale
(Alexander Reelsen)
May 11, 2022, 1:43pm
2
Not nice, but may help you:
POST _render/template
{
"source": "{ \"coordinates\": [ {{longitude}}, {{latitude}} ]}",
"params": {
"longitude": 1,
"latitude":2
}
}
stephenb
(Stephen Brown)
May 12, 2022, 1:50am
4
Ok I will take a swing
How about without the "
around the lat / lon
"coordinates": [
{{longitude}},
{{latitude}}
NOPE that does not work
RE-EDITING... Strange Results
yeziblo
(yeziblo)
May 12, 2022, 8:14am
5
yeah, I removed the " too.
spinscale
(Alexander Reelsen)
May 12, 2022, 9:00am
6
can you share what you tried instead of writing 'does not work'? thanks
Have you tried to define your shape using WKT?
POST _scripts/geoshape_search
{
"script": {
"lang": "mustache",
"source": {
"query": {
"geo_shape": {
"geo_json" : {
"shape": "POINT({{longitude}} {{latitude}})",
"relation": "intersects"
}
}
}
}
}
}
1 Like
stephenb
(Stephen Brown)
May 12, 2022, 2:42pm
8
GET _render/template
{
"id": "geoshape_search",
"params": {
"longitude": -121.77777,
"latitude": 37.33333
}
}
{
"template_output" : {
"query" : {
"geo_shape" : {
"geo_json" : {
"shape" : "POINT(-121.77777 37.33333)",
"relation" : "intersects"
}
}
}
}
}
That seems to work I tried with {{#toJson}}
and could not get it to work...
system
(system)
Closed
June 9, 2022, 2:42pm
9
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.