Skip to content Skip to sidebar Skip to footer

BadFilterError: Invalid Filter: Only One Property Per Query May Have Inequality Filters (<=, >=, <, >)

I am trying to apply filter on two diffrent properties but it GAE isn't allow me to do this what will be the solution then, there it is the code snipt: if searchParentX : que.

Solution 1:

The solution would be to do an in memory filtering:

  1. You can run two queries (filtering on one property each) and do an intersection on the results (depending on the size of the data, you may need to limit your results for one query but not the other so it can fit in memory)
  2. Run one query and filter out the other property in memory (in this case it would be beneficial if you know which property would return a more filtered list)

Alternatively, if your data is structured in such a way that you can break the data into sets you can perform equality filters on that set and finish filtering in memory. For example, if you are searching on strings but you know the strings to be a fixed length (say 6 characters), you can create a "lookup" field with the begging 3/4 characters. Then when you need to search on this field, you do so by matching on the first few characters, and finish the search in memory. Another example: when searching for integer ranges, if you can define common grouping of ranges (say decades for a year, or price ranges), then you can define a "range" field to do equality searches on and continue filtering in memory


Solution 2:

Inequality filters are limited to at most one property, i think this restriction is because the data in bigtable is stored in lexical sorted form so at one time only one search can be perform

https://developers.google.com/appengine/docs/python/datastore/queries#Restrictions_on_Queries


Post a Comment for "BadFilterError: Invalid Filter: Only One Property Per Query May Have Inequality Filters (<=, >=, <, >)"