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

Sec. index: make json array elements be encoded with depth information #3329

Open
Tracked by #201
islamaliev opened this issue Dec 16, 2024 · 0 comments
Open
Tracked by #201
Labels
area/datastore Related to the datastore / storage engine system area/query Related to the query component perf Performance issue or suggestion

Comments

@islamaliev
Copy link
Contributor

islamaliev commented Dec 16, 2024

Depth information for array elements allow to be more specific about which items you want to deal with.

At the moment we store all array element values as if they were just normal scalar fields on a json doc.

Lets say we have this schema:

type User {
  name: String 
  custom: JSON @index
}

And we create this documents:

{
  "name": "Andy",
  "custom": {
    "numbers": 4,
  }
}
{
  "name": "John",
  "custom": {
    "numbers": [3, 4],
  }
}

And then query:

query {
  User(filter: {custom: {numbers: {_none: {_eq: 4}}}}) {
    name
  }
}

This will result at the moment in an empty result, but correct behaviour would be to return "Andy" document as its number is not an array and shouldn't be checked against _none.

The indexes are stored roughly as follows:

/1/1/custom.number/3/john-doc-id
/1/1/custom.number/4/andy-doc-id
/1/1/custom.number/4/john-doc-id

CocroachDB uses arr suffix. With it the indexes might look like:

/1/1/custom.number/arr/3/john-doc-id
/1/1/custom.number/arr/4/john-doc-id
/1/1/custom.number/4/andy-doc-id
@islamaliev islamaliev added area/query Related to the query component area/datastore Related to the datastore / storage engine system perf Performance issue or suggestion labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/datastore Related to the datastore / storage engine system area/query Related to the query component perf Performance issue or suggestion
Projects
None yet
Development

No branches or pull requests

1 participant