0
votes

I'm currently doing some tests on google datastore, but I'm having a problem with my queries.

If I believe in the documentation https://cloud.google.com/datastore/docs/concepts/queries we can realize a filter on several columns with the instruction EQUALS.

But when testing, I get an error from the API. While searching on Datastore's github, I found this reference: https://github.com/GoogleCloudPlatform/google-cloud-dotnet/issues/304 which corresponds to my problem, except that for my case the query to the look good.

Here is the request sent:

{
  {
    "kind": [{
      "name": "talk.message"
    }],
    "filter": {
      "compositeFilter": {
        "op": "AND",
        "filters": [{
            "propertyFilter": {
              "property": {
                "name": "Conversation"
              },
              "op": "EQUAL",
              "value": {
                "stringValue": "2f16c14f6939464ea687d316438ad4cb"
              }
            }
          },
          {
            "propertyFilter": {
              "property": {
                "name": "CreatedOn"
              },
              "op": "LESS_THAN_OR_EQUAL",
              "value": {
                "timestampValue": "2019-03-15T10:43:31.474166300Z"
              }
            }
          },
          {
            "propertyFilter": {
              "property": {
                "name": "CreatedOn"
              },
              "op": "GREATER_THAN_OR_EQUAL",
              "value": {
                "timestampValue": "2019-03-14T10:43:31.474175100Z"
              }
            }
          }
        ]
      }
    }
  }
}

And here is the answer from the API:

{Grpc.Core.RpcException: Status(
      StatusCode=FailedPrecondition, 
      Detail="no matching index found. recommended index is:
              - kind: talk.message
                properties:
                - name: Conversation
                - name: CreatedOn"
     )

According to the documentation, this should be good... but it's not ! What am I missing ?

1

1 Answers

0
votes

Your query includes both an EQUALS (on Conversation) and a non-EQUALS filter (on CreatedOn), therefore you need a composite index to fulfil the query. So your query is valid, but it needs a composite index to be able to run the query.