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

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

Closed
2 tasks done
rajesh-melige opened this issue Aug 11, 2021 · 8 comments
Assignees
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

Comments

@rajesh-melige
Copy link

rajesh-melige commented Aug 11, 2021

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
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. 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 labels Aug 11, 2021
@joshfree joshfree changed the title [FEATURE REQ] How to filter results using azure-spring-data-cosmos-core-query Criteria and CriteriaType "ARRAY_CONTAINS" Aug 11, 2021
@joshfree joshfree added 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. labels Aug 11, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 11, 2021
@joshfree
Copy link
Member

@backwind1233 @yiliuTo could you please follow up with @rajesh-melige on this question?

@kushagraThapar
Copy link
Member

@mbhaskar - can you please help on this issue ?

@rajesh-melige
Copy link
Author

@mbhaskar @kushagraThapar May I know if you have any update on this issue ? We are blocked on this implementation.

@chenrujun chenrujun moved this to Todo in Spring Cloud Azure Nov 5, 2021
@chenrujun chenrujun added this to the Backlog milestone Nov 22, 2021
@shitikovegor
Copy link

@mbhaskar @kushagraThapar can you write if you have any updates on this issue?

@kushagraThapar
Copy link
Member

@shitikovegor - one of the customers is using this as a solution - #25628 (comment)
Let me know if that helps.

@shitikovegor
Copy link

@kushagraThapar everything work with @query annotation, but I mean this issue is about 'ARRAY_CONTAINS' criteria in method name as keyword

@kushagraThapar
Copy link
Member

@trande4884 - can you please take a look at this, thanks!

@trande4884
Copy link
Member

@shitikovegor per the documents here, the boolean flag for partial matching only pertains to ARRAY_CONTAINS with objects. Our SDK does not currently support this. Criteria only supports ARRAY_CONTAINS with single property values.

Repository owner moved this from Todo to Done in Spring Cloud Azure Aug 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
Archived in project
Development

No branches or pull requests

8 participants