1

So I'm trying to run a query on Google Cloud's datastore as such:

let query = datastore.createQuery(dataType)
    .select(["id", "version", "lm", "name"])
    .filter("owner", "=", request.params.owner)
    .filter("lm", ">=", request.query.date_start)
    .groupBy(["lm"])
    .order("lm")

Yet I run into an error stating that

no matching index found. recommended index is:
- kind: Entry
  properties:
  - name: lm
  - name: id
  - name: name
  - name: version

When I run the query with id instead of lm for all the methods I run into no errors. Is this because in my index.yaml file I have the index as such: ?

- kind: Entry
  properties:
  - name: id
  - name: version
  - name: lm
  - name: name

Must I actually create a new index with the recommended ordering? Or is there a way I can do this without having to make another index? Thank you!

uccblack
  • 107
  • 2
  • 9

1 Answers1

3

Yes, you need to create a new index, the existing one you showed is not equivalent, so it can't be used for your query - the property order matters (at least for the inequality filters and sorting). See related Google Datastore Composite index issue

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97