为什么POST和NOT在弹性搜索头UI“任何请求” [英] Why POST and not GET in elasticsearch head UI "any Request"

查看:162
本文介绍了为什么POST和NOT在弹性搜索头UI“任何请求”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似的问题,如
问这里

我在头插件中运行以下查询,任何请求选项卡(使用_search端点和GET):

I was running the following query in the head plugin, any request tab (with _search endpoint and GET):

{
    "query": {
    "match": {
    "body": "mulla"
}}}

我所有的文件都被打了,所有的成绩都是1,例如ConstantScore(*:*)。

all my documents were a hit and all had score of 1, with explain saying something like ConstantScore(*:*).

在链接的问题中,有人回复说,您必须确保使用POST而不是GET,这可以按预期方式工作(返回一个子集所有文件的分数不同)。这是我的问题,为什么POST而不是GET?弹性搜索指南中的比较例子使用GET。

In the linked question someone replied that you have to be sure to use POST and not GET, which works as expected (returning a subset of all documents with different scores).Which is my question why POST and not GET? Comparable examples in the elasticsearch guide say to use GET.

如果我使用curl运行相同的请求:

Also if I run the same request with curl:

curl -i -XGET 'http://localhost:9200/dagb/_search' -d '
{
"query": {
"match": {
"body": "mulla"
 }}}'

它按预期工作,在头插件中提供与POST请求相同的分数和文档。另外我刚刚检查,使用-XPOST的卷曲版本也可以使用。

It works as expected, giving same scores and documents as the POST request, in the head plugin. Additionally I just checked , the curl version with -XPOST also works.

推荐答案

使用google chrome开发人员工具,您可以看到请求这是执行。如果您使用头插件并将请求的类型从POST更改为GET,则不会将json文档作为正文发送。该json文档附加到请求。弹性搜索不支持。请求必须作为请求正文发送。使用卷曲你会发送它作为一个身体。以下是执行请求的示例。

Using google chrome developer tools, you can see the request that is performed. If you use the head plugin and change the type of request from POST to GET, the json document is not send as the body. The json document is appended to the request. That is not supported by elasticsearch. The request has to be send as a request body. Using curl you do send it as a body. Below an example of the executed request.

http:// localhost:9200 / gridshore / _search ?{%22query%22:{%22match%22:{%22content%22:%22cool%22}}}

http://localhost:9200/gridshore/_search?{%22query%22:{%22match%22:{%22content%22:%22cool%22}}}

最后弹性搜索将这个查询与

In the end elasticsearch treats this query the same as

http:// localhost:9200 / gridshore / _search

这篇关于为什么POST和NOT在弹性搜索头UI“任何请求”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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