How to filter results using azure-spring-data-cosmos-core-query Criteria and CriteriaType "ARRAY_CONTAINS" #23485
Closed
2 tasks done
Labels
azure-spring
All azure-spring related issues
azure-spring-cosmos
Spring cosmos related issues.
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone
Is your feature request related to a problem? Please describe.
I want to filter the result set using azure-spring-data-cosmos-core-query Criteria and CriteriaType "ARRAY_CONTAINS".
I have the Result set structure similar to this:
{
"id": "UUID",
"name": "…",
"emailAddress": "…",
"version",
"arrayField": [
{
"id": "UUID",
"status": "active",
"name": "abc"
},
{
"id": "UUID",
"status": "draft",
"name": "xyz"
},
{
"id": "UUID",
"status": "active",
"name": "qwe"
},
…
],
"country": "",
…
}
I would like to query on arrayField.id which is a unique field.
The implementation for the ARRAY_CONTAINS is ARRAY_CONTAINS(object.arrayField, { "id": "UUID_value" }, boolean), where the boolean value "true" implies to match the partial array and "false" implies otherwise.
Since I'm using the Criteria to build my query, there is no supported method of getInstance in the Criteria class to set the boolean value for ARRAY_CONTAINS condition.
So, the boolean value is "false" by default and I'm not able to filter the results for partial array match.
Every time the result set is empty because it is matching the entire array not just one field.
Describe the solution you'd like
I would like to have an additional boolean field in the Criteria class to set the value for ARRAY_CONTAINS condition.
Also an additional method of getInstance which will accept that boolean value.
This would also need some changes in the azure-spring-data-cosmos-core-generator AbstractQueryGenerator for generating the ARRAY_CONTAINS query.
Describe alternatives you've considered
This could be done using the JOINS but then I cannot use the Criteria implementation and also I cannot use SELECT * from root.
I also found a similar issue at #16676. But that is restricted to sql query implementation and not using the Criteria class.
Additional context
Add any other context or screenshots about the feature request here.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: