Explorer
Explorer copied to clipboard
`whereIn` not accepting integers
Hi π,
First of all thank you for this amazing package. I Just started learning the basics of Elastic Search.
I was trying to do filtering like this:
User::search("")->whereIn('id', [1, 2, 3])->get();
It throws error: Expected a string. Got: integer
If I do,
User::search("")->where('id', 1)->get();
It works completely fine.
I mean I could definitely manually transform them to string,
Just the different allowed types for where
and whereIn
seemed odd.
Is this intentional?
Thanks again π
Can you locate where the error is from? As far as I know where and whereIn are part of Laravel and not Explorer. So I'm curious for the stacktrace :)
Previously I was using Meilisearch driver, it was working fine with integers whereIn('id', [1, 2, 3])
The error is coming from here:
Ah ok. From the docs:
value (Required, string) Term you wish to find in the provided
. To return a document, the term must exactly match the field value, including whitespace and capitalization.
So they need to be strings for this Elasticsearch syntax.
Hmm, but then why does where
works with integer
and not whereIn
π€
Because where uses the Term syntax and whereIn uses Terms, and someone forgot to add the assertion to Term. π΅οΈ
Honestly, the where is working fine. I can pass integers and it filters as expected.
So I think safe to remove the assertion from whereIn? Or atleast allow strings and numbers as well.
Feel free to test, verify and if so create a PR!