-
Notifications
You must be signed in to change notification settings - Fork 981
Use POST method for search requests with body #737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
Both are valid. GET requests can use a body; it isn't forbidden by the HTTP spec. See the callout titled "A GET Request with a Body?" at: https://www.elastic.co/guide/en/elasticsearch/guide/current/_empty_search.html for more details. That said, if you need to change the HTTP method to better suit your environment, you can override it: $client = Elasticsearch\ClientBuilder::create()->build();
$params = [
'index' => 'test',
'type' => 'test',
'body' => [
'query' => [
'match_all' => []
]
],
'client' => [
'curl' => [
CURLOPT_CUSTOMREQUEST => 'POST'
]
]
];
$client->search($params); As an aside, running search requests through a caching proxy is probably a bad idea. They could easily cache a search request that is no longer valid because the underlying data has changed. Caching other API endpoints may make sense, but caching search rarely does. Elasticsearch has several built-in caches at various levels, so a top-level caching layer is not usually needed (and can lead to data inconsistency or confusing situations). E.g. imagine the results are cached, user clicks on one of the hits for more information then the following GetDocument API fails because the document was actually deleted (but the search hits were cached). |
Summary of problem or feature request
GET requests with a body are wrong for some proxies. POST request type works. GET requests can't contain the body, that is the reason.
Code snippet of problem
-->
System details
The text was updated successfully, but these errors were encountered: