Skip to content
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

whereIn not accepting integers #230

Open
Aniket-IN opened this issue Jan 14, 2024 · 7 comments
Open

whereIn not accepting integers #230

Aniket-IN opened this issue Jan 14, 2024 · 7 comments

Comments

@Aniket-IN
Copy link

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 😊

@Jeroen-G
Copy link
Owner

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 :)

@Aniket-IN
Copy link
Author

Previously I was using Meilisearch driver, it was working fine with integers whereIn('id', [1, 2, 3])

The error is coming from here:
image

@Jeroen-G
Copy link
Owner

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.

@Aniket-IN
Copy link
Author

Hmm, but then why does where works with integer and not whereIn 🤔

@Jeroen-G
Copy link
Owner

Because where uses the Term syntax and whereIn uses Terms, and someone forgot to add the assertion to Term. 🕵️

@Aniket-IN
Copy link
Author

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.

@Jeroen-G
Copy link
Owner

Feel free to test, verify and if so create a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants