1

I'm trying to run a query on a ListProperty field named "numericRange". There is a row that has value ["3","5"] for this field. I want to verify that value "4" belongs to this range.

If I run the next query on GQL console, datastore returns results (because the first value "3", matches):

select * from example where numericRange<=4

If I run the next query, also datastore returns results (because the second value "5", matches):

select * from example where numericRange>=4

However If I run the next query, datastore doesn't return results:

select * from example where numericRange<=4 and numericRange>=4

Why does it work on the first and second queries, but not on the third query?

Thank you in advance.

1 Answers1

1

Cloud Datastore flattens your list for the indexes. So your query numericRange<=4 and numericRange>=4 is checking the index to see if (3<=4 and 3>=4), and if (5<=4 and 5>=4). As you can see, with a flattened values in the index your 3rd query will only return results when numericRange has a value in the list of exactly 4.

Jim Morrison
  • 2,784
  • 1
  • 7
  • 11
  • Thanks! I understood something different when I read this https://cloud.google.com/appengine/docs/standard/python/datastore/typesandpropertyclasses#ListProperty and this https://stackoverflow.com/questions/3338109/between-query-equivalent-on-app-engine-datastore?answertab=active#tab-top – Rubén Cervilla Mar 07 '18 at 10:26