ElasticSearch.如何将数组传递给搜索模板 [英] ElasticSearch. How to pass array to the search template

查看:44
本文介绍了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

这篇关于ElasticSearch.如何将数组传递给搜索模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆