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

Enable documents filtering by inline array fields #2857

Closed
islamaliev opened this issue Jul 22, 2024 · 0 comments · Fixed by #3028
Closed

Enable documents filtering by inline array fields #2857

islamaliev opened this issue Jul 22, 2024 · 0 comments · Fixed by #3028
Assignees
Labels
area/query Related to the query component priority/high
Milestone

Comments

@islamaliev
Copy link
Contributor

islamaliev commented Jul 22, 2024

currently we allow filtering of documents by related objects:

query {
  Author(filter: {
    books: {rating: {_gt: 3}}
  }) {
    name
    books {
      name
    }
  }
}

But there is no way we can do it for inline arrays like [String].
One of the ideas is to introduce new operators _all, _any and _none that should count number of filter matches for every element in the array:

query {
  Author(filter: {
    genres: {_any: {_eq: "Horror"}}
  }) {
    name
  }
}
query {
  Author(filter: {
    publishedYears: {_all: {_gt: 2010}}
  }) {
    name
  }
}

Alternatively (or additionally) we can integrate aggregates into filters with their own filters within:

query {
  Author(filter: {
    _count(books: { filter: {
      rating: {_gt: 3}
    }}): {_eq: 2}
  }) {
    name
  }
}

This would allow us to specify exactly how many matching elements should be in the array.

Tangentially related idea:
it might be also useful to request indexes of matching elements into the array and potentially afterwards use them to manipulate the array.

@islamaliev islamaliev added the area/query Related to the query component label Jul 22, 2024
@fredcarle fredcarle added this to the DefraDB v0.14 milestone Aug 23, 2024
@nasdf nasdf self-assigned this Sep 16, 2024
@nasdf nasdf mentioned this issue Sep 18, 2024
4 tasks
@nasdf nasdf closed this as completed in 55e56a5 Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component priority/high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants