4
votes

For some reason one of my composite index with google datastore is not working.

I am getting zero results with the following query:

SELECT * FROM `Foobar` WHERE `ver` = 20180814 AND `level` = 1

However the index is created (though showing zero size even though it has been created couple of days ago):

screenshot of created+serving index

I double checked that the fields are both integers and I am also getting zero results on the local sdk.

index.yaml:

indexes:

- kind: Foobar
  properties:
  - name: ver
  - name: level
    direction: desc
1
Have you added data since the creation of this index? Indexing a property does not affect any existing entities that may have been created before this indexing action. - amport
@Mangu this is a composite index, not a property-index on entity-level. Meaning no entity updates are required for this to work - but in any case I also added data with unfortunately no luck. - lifeofguenter
ok turns out that it might be required for composite indices to work that the properties themselves are indexed as well... not sure if I missed that in any documentation but will double check.. - lifeofguenter
From Index definition and structure: An entity is included in the index only if it has an indexed value set for every property used in the index; - Dan Cornilescu

1 Answers

4
votes

as pointed out by @Dan, composite indices only work if the property of the entity is indexed itself (built-in), see: https://cloud.google.com/datastore/docs/concepts/indexes#index_definition_and_structure

An entity is included in the index only if it has an indexed value set for every property used in the index