appwrite: Bug : Query an Array attribute with an array of values does not work
๐ Reproduction steps
I am trying to query a Collection where one attribute is an Array of string
Trying this syntax fails to retrieve anything (and it feels normal)
database.list_documents('collection',
[
Query.equal("array_attribute, ["value1","value2"])
]
))
Trying this syntax fails also while it feels like it could work ๐
database.list_documents('collection',
[
Query.equal("array_attribute, '["value1","value2"]')
]
))
What I am trying to do is basically an โArray IN Arrayโ comparison. Going the โequalโ way seems hackish but I thought as the attribute is stored in a String it might work (and could be a work-around until a proprer โinโ or โcontainsโ operator exists. ?)
My only other option to make this work is use a function to โexplodeโ the values contained in array_attribute in a new collection and then I can do a OR comparaison. It works but is not as straighforward + it generates a big collection.
๐ Expected behavior
some content is being retrieved
๐ Actual Behavior
Nothing is retrieved.
๐ฒ Appwrite version
Version 0.12.x
๐ป Operating system
Linux
๐งฑ Your Environment
No response
๐ Have you spent some time to check if this issue has been raised before?
- I checked and didnโt find similar issue
๐ข Have you read the Code of Conduct?
- I have read the Code of Conduct
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 24
- Comments: 21 (3 by maintainers)
I dont know if it is helpful, but i found out that you can use Query.search to looking for items in array.
This is not really supported as of right now, every possible solution will come with its downsides ๐๐ป
We are working on a way to query the contents of an array.
Is there any update on this issue ? Iโm planing to have a tag search in an app so I search and found this thread.
@stnguyen90 I think making the single param called exact match make more sense as we can overloaded the function for partial matching. I propose sample use cases and syntax representation as follow.
Also, tag use case will need distinct query so we will know all available tag list before the query. I didnโt see query distinct in the doc but it can be temporary fixed by having a unique list updated as each record created or updated. However, I think distinct query should be available for every attribute types.
@meepeek, @superseby2, for this type of functionality, are you expecting for documents to return if they have any least one of the values in the query? For example, letโs say the document has
["flutter", "dart"]
for attributetags
.Query.contains("tags", ["flutter", "react"])
would return the document becauseflutter
is in thetags
. Is this the functionality you need?