1

I have a search system in which i need to score by location. User sends his coordinates, I check whether they intersect with pre-indexed polygons. The problem is I don't know how to pass coordinates to json file. I use python library called elasticsearch.
Here is sample of how I pass search data to search templateHere is sample of how I pass search data to search template

And this is how I'm trying to use it in search template file enter image description here

But the problem is it gets parsed as a string, but I need an array of floats.

Zhanara
  • 107
  • 2
  • 8

1 Answers1

0

For coordinates,use this format : "coordinates" : [[-77.03653, 38.897676], [-77.009051, 38.889939]] https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-shape.html

For the score please join us exemple and what you expect, but pretty sure you will have to use a https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

LeBigCat
  • 1,737
  • 1
  • 11
  • 16
  • Talking about coordinates, these coordinates are passed to json from python code using function search_template, and the only way to get it in json file is like this "{{coordinates}}", I pass a list but it gets type casted to string, when I'm accessing it in json, I can't find a way How can i get it as list – Zhanara Mar 06 '19 at 10:33
  • I want to increate score of restaurants, which polygons intersect with the point I pass. Client app passes me user location, and I'm making search in accordance with user coordinates and boost the ones which intersect with my point – Zhanara Mar 06 '19 at 10:37
  • So a sort by distance would be ok? – LeBigCat Mar 06 '19 at 10:55
  • Actually,no. Because these polygons represent delivery areas of a restaurant, it's not so important how far they are, as if this location is in this polygon. If it is I need to boost its score – Zhanara Mar 06 '19 at 10:58
  • Ok can you join us 1 or 2 example? We should be able to resolve the score part. For the coordinates i cant help you, not relate to elasticsearch, you certainly have to use another json serializer or custom your formater. You should also post your code for this problem. – LeBigCat Mar 06 '19 at 11:18