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

[Improvement]: Can $in be added as a logic operator for Query filters? #870

Closed
jonathan-dejong opened this issue Jul 4, 2024 · 3 comments

Comments

@jonathan-dejong
Copy link

jonathan-dejong commented Jul 4, 2024

Improvement description

I've got this scenario where I have a select field containing a bunch of site names with site ids as values.

I would like to be able to filter my query so that I can get the objects where the value of this field is either null OR one of the values is a specific ID that I pass to the filter.

I believe it would be something like this, in this example I'm getting the ProductSimple objects if the ProductSites select field contains 1,2 or 4 as values.

getProductSimpleListing(filter: "{ \"$or\": [{\"ProductSites\": \"null\"}, {\"ProductSites\": {\"$in\": [\"1,2,4\"]}}], }") {

However $in is not a supported operator so this simply gives me an Internal server error.
At least that is what I think is happening..
Because this is the old docs:
https://pimcore.com/docs/pimcore/6.9/Development_Documentation/Web_Services/Query_Filters.html

And in the new docs, I've not been able to find a similar reference.

I know that I can use $like BUT that gives false positives.

\"$or\": [{\"ProductSites\": \"null\"}, {\"ProductSites\": {\"$like\": \"%1%\"}}]

This will return results where productSites contains a value of 12, 21, 201 etc.

As a sidenote/question:
I don't think this way of checking for null works either, but I am not sure how to do it.. if anyone knows I'd gladly take your input!

@jonathan-dejong
Copy link
Author

This is the best I've been able to achieve right now.

filter: "{ \"$or\": [ { \"ProductSites\": null }, { \"ProductSites\": { \"$like\": \"%11%\" } } ] }"

This seems to work for checking null and a LIKE for the ID.. which does still give false positives but it's the best option it seems until such time that IN is a valid operator.

Copy link

Thanks a lot for reporting the issue. We did not consider the issue as "Pimcore:Priority", "Pimcore:ToDo" or "Pimcore:Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

@fashxp
Copy link
Member

fashxp commented Oct 2, 2024

No, $in is not implemented. Only $not, $or, $and and $like are supported.

We are thinking about moving to PQL for filtering, see #891 and https://pimcore.com/docs/platform/Generic_Data_Index/Searching_For_Data_In_Index/Pimcore_Query_Language/

Actually, there is also not something like IN, but syntax still should be much more convenient.

@fashxp fashxp closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants