Skip to content

How to filter results using azure-spring-data-cosmos-core-query Criteria and CriteriaType "ARRAY_CONTAINS" #23485

Closed

Description

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

  • Description Added
  • Expected solution specified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.azure-springAll azure-spring related issuesazure-spring-cosmosSpring cosmos related issues.customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions