tigris icon indicating copy to clipboard operation
tigris copied to clipboard

Support filter's dot notation for arrays

Open rumyantseva opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

To support more user queries, we need the ability to use "dot notation" in the filter when searching for values in arrays.

Examples:

  • foo.0.bar.1 - to address the exact array value with the given indexes
  • foo.bar - to address any array element in foo.*.bar.* arrays

Usage example:

filter = `{"foo.0.bar.1": "hello"}` // the exact array element is "hello"
filter = `{"foo.bar": "hello"}` // any element of `foo.*.bar.*` array is "hello"

Additional context

To support more query pushdown cases in FerretDB.

rumyantseva avatar Feb 16 '23 18:02 rumyantseva

@garrensmith let's think about this use case as well for filtering on array fields.

himank avatar Feb 16 '23 18:02 himank

Nice. This should be possible with the secondary indexes. We have to change the keybuilder and filter to support nested queries. The part I'm uncertain around is the foo.Position1.bar.Position2 I think that part would have to be done in memory.

garrensmith avatar Feb 16 '23 18:02 garrensmith

Add support for lambda style filtering. There are two examples we can refer to:

duckdb nested functions: https://duckdb.org/docs/sql/functions/nested - list_filter jsonpath - https://goessner.net/articles/JsonPath/

kesavkolla avatar Apr 19 '23 16:04 kesavkolla