ElasticSearch.如何将数组传递给搜索模板

ElasticSearch.如何将数组传递给搜索模板

问题描述:

我有一个搜索系统,需要在其中按位置评分.用户发送他的坐标,我检查它们是否与预索引的多边形相交.问题是我不知道如何将坐标传递到json文件.我使用的是称为Elasticsearch的python库.
这里是如何将搜索数据传递到搜索模板的示例

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 template

这就是我试图在搜索模板文件中使用它的方式

And this is how I'm trying to use it in search template file

但是问题是它被解析为字符串,但是我需要一个浮点数数组.

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

对于坐标,请使用以下格式:坐标":[[-77.03653,38.897676],[-77.009051,38.889939]] https://www.elastic.co/guide/zh/elasticsearch/reference/current/geo-shape.html

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