在Python中将multi_match与Elasticsearch批量扫描一起使用

时间:2018-11-09 19:16:19

标签: python elasticsearch elasticsearch-py

我正在尝试通过elasticsearch-py库在Elasticsearch中使用\copy ... from stdin功能。

按如下所示进行设置:

multi_match

我得到:

  

RequestError:RequestError(400,'parsing_exception','未知密钥   [multi_match]中的START_OBJECT。')

任何人都知道是否可以使用Elasticsearch-py库进行此搜索吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

我认为查询不正确。每当我们观察到parsing_exception时,我们首先需要确保通过KibanaPostman或指向ES实例的任何其他RESTful client application进行查询。

您的代码必须采用以下格式。

res = helpers.scan(es, index="allcomms", query = { "query" : {
      "multi_match" : {
      "query": "multiple terms", 
      "fields": ["text"] 
  }}})

基本上,下面是您的multi-match查询的结果

POST <your_index_name>/_search
{  
   "query":{  
      "multi_match":{  
         "query":"multiple terms",
         "fields":[  
            "text"
         ]
      }
   }
}

让我知道是否有帮助!