将弹性搜索查询转换为其余调用参数

时间:2017-11-06 10:51:50

标签: python elasticsearch kibana

我正在处理kibanaelasticsearch。我在elasticsearch中索引了文档。现在,我想创建一个用户界面并使其可以像这样搜索:



GET /complete_index/_search
{
  
 
   "query":
   {
     "multi_match": {
       "query": "broker connection",
       "operator":"and",
       
       "fields": ["post_subject","topic_title"]
       
     }
    
   
 },
 "from": 0,
 "size": 50, 
 "_source":  ["post_id","topic_id","post_subject","topic_title"]
}




我无法将elasticsearch查询作为数据传递给休息调用。我该如何纠正?

1 个答案:

答案 0 :(得分:0)

使用curl请求对Elasticsearch进行休息调用,如下所示。

curl -XGET "https://f03cadb8fd043aa17dcce6850f4646e7.ap-southeast-1.aws.found.io:9243/complete_index/_search" -H 'Content-Type: application/json' -d'
{"query":{"multi_match":{"query":"broker connection","operator":"and","fields":["post_subject","topic_title"]}},"from":0,"size":50,"_source":["post_id","topic_id","post_subject","topic_title"]}'