Allow filtering in stored JSON objects #7277
Replies: 13 comments 16 replies
-
Because now we can filter records by a json field with "is null" or "isn't null" and is a bit annoying and frustrating. |
Beta Was this translation helpful? Give feedback.
-
this feature would be great. json functions are already in Knex, so it probably wouldn't require custom magic per DB driver: http://knexjs.org/#Builder-whereJsonObject |
Beta Was this translation helpful? Give feedback.
-
@rijkvanzanten Is there any workaround or hack to filter in JSON objects now? |
Beta Was this translation helpful? Give feedback.
-
Any chance of this coming back to the API? |
Beta Was this translation helpful? Give feedback.
-
This issue just got a little bump via #14894. |
Beta Was this translation helpful? Give feedback.
-
Just want to resurface this discussion/issue because it's been since May 2022 that I discovered it also affect's built-in Directus tables as well as being a user limitation. In short, the Tags field in the Directus file library is essentially useless. This is because the purpose of tags is generally understood to be to enable searching/filtering items based on whether a given tag is present, but since the tags field in the Directus file library is (presumably) a JSON object, we can't actually use it for searching/filtering. When you try filter on it you get the options "Is null" and "Isn't null", both of which make no sense in the context of tags. I'd honestly argue that the Tags field should just be removed entirely until this issue is resolved, because right now what exactly would anyone use it for other than searching/filtering as described above? I think this issue is more of a problem than it initially appeared. Alternatively, the Tags field could be converted to an actual database relation, but I think the more helpful direction is to focus on resolving this issue and bring the benefits of JSON filtering to everyone. |
Beta Was this translation helpful? Give feedback.
-
Great to see the support on Rest API. But, when do you plan to add it on UI ? |
Beta Was this translation helpful? Give feedback.
-
Heya! Thanks for opening this feature request! This feature request has received over 15 votes from the community. This means we'll move this feature request to the Under Review state! The Core team will schedule a meeting to review this request as soon as possible. The discussion will then be approved or denied. You may or may not be invited to join this meeting with the core team. For more information, see our Feature Request Process. |
Beta Was this translation helpful? Give feedback.
-
Data Abstraction Project dependent:
|
Beta Was this translation helpful? Give feedback.
-
On January 11 we're inviting you to come and have a chat with us about this feature request at our Request Review in our Discord server. This will help us have some dedicated time to talk about what implementation would have the most sense. Please feel free to join us as https://directus.chat (the event is already listed and you can set a reminder) |
Beta Was this translation helpful? Give feedback.
-
Feature Request Session Notes
Tim: I divided it up in 3 different functionalities in that old #15889
Is the idea to integrate Directus's existing filters/aggregate/Dynamic Variables function or would there be new JSON specific functions?
psql allows for dateranges (a JSON array) and I built a custom daterange interface/display for this but can't filter with it. Is that something that would be supported by this pr or would that be something else?(unsure of other DBs)
Could you consider using JSON schema to type and validate fields.
|
Beta Was this translation helpful? Give feedback.
-
Hi! Is there a timeline for this feature to also come to the UI? :) |
Beta Was this translation helpful? Give feedback.
-
greetings, I am also interested in this issue, I hope it is resolved soon, as I see that the issue has been going on for several years. |
Beta Was this translation helpful? Give feedback.
-
Some databases, like Postgres and more recent versions of MySQL have (limited) capabilities to search in JSON objects, instead of treating them as a flat value. Postgres f.e. has a dedicated syntax for it, where MySQL has a "EXTRACT_JSON" function that can be used to extract values from the JSON object.
Seeing this would require a lot of custom magic per DB driver, I think this could be implemented in a similar fashion as the date extraction functions (
year(datetime_created)
etc):The second argument would be a dot-notation path of where to find the value in the JSON, similar to
lodash
esget
functionBeta Was this translation helpful? Give feedback.
All reactions