-
Notifications
You must be signed in to change notification settings - Fork 965
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
Handle null 'type' parameter in search #559
Comments
FYI I've worked out I can achieve my desired outcome with $response = $client->search([
'index' => 'myapp',
'type' => $_GET['type'] ?? '',
'body' => /*...*/
]); Still, better handling of |
Agreed! Your suggested fix looks good, I need to patch up a few more (entirely unrelated) issues then I'll push a fix. :) |
p365labs
pushed a commit
to p365labs/elasticsearch-php
that referenced
this issue
Sep 10, 2017
p365labs
pushed a commit
to p365labs/elasticsearch-php
that referenced
this issue
Sep 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary of problem or feature request
If you pass
'type' => null
to$client->search()
, instead of (1) returning all types or (2) showing a useful error message (e.g. Invalid type), it returns this error:I believe this is because
search()
calls:And
extractArgument()
checks for the parameter using isset():Which returns
false
when used onnull
values. If it usedarray_key_exists($arg, $params)
instead ofisset($params[$arg])
I think it would work as expected - remove the key from $params, return null and therefore return all types.My reason for wanting to be able to pass null to get all types is simply so I can do this:
Instead of this:
But if that can't / won't be supported for any reason, a better error message would be nice.
Thanks!
Code snippet of problem
System details
The text was updated successfully, but these errors were encountered: