0

I am not able to query on datetime fields in google app engine. I am trying to run the following query -

SELECT * FROM Email WHERE cmp_id='52d836ed1057c341b800013a' AND pushed_to_crm=TRUE AND ss_time >= DATETIME('2014-01-17 00:00:00')

I am sure that this should return some rows - I mean that there is data in the database that should be returned.

But I get an error in running this query -

Learn more about GQL syntax.
no matching index found.
The suggested index for this query is:
- kind: Email
  properties:
  - name: cmp_id
  - name: pushed_to_crm
  - name: ss_time

The field ss_time is db.DateTimeProperty(). Is there something that I am missing?

Siddharth
  • 5,009
  • 11
  • 49
  • 71

1 Answers1

1

The error message is quite clear. You have to add index for your Email entity with the following attributes: cmp_id, pushed_to_crm and ss_time.

You can do that by adding the following to your index.yaml:

- kind: Email
  properties:
  - name: cmp_id
  - name: pushed_to_crm
  - name: ss_time
Loša
  • 2,621
  • 2
  • 14
  • 19
  • I created the indexes and deployed. I can see that the indexes has been created but I am still getting the same error. – Siddharth Feb 21 '14 at 20:09
  • Oh! I got it... you have to create indexes for each query. So if a query on the Email entity uses two properties, you need to create an index for those two properties. If again, you have a query on Email entity for two different properties, you need to create an index for those two properties separately. – Siddharth Feb 21 '14 at 23:14