BadFilterError:无效过滤器:每个查询只有一个属性可能具有不等式过滤器(< =,> =,<>) [英] BadFilterError: invalid filter: Only one property per query may have inequality filters (<=, >=, <, >)

查看:135
本文介绍了BadFilterError:无效过滤器:每个查询只有一个属性可能具有不等式过滤器(< =,> =,<>)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在两个不同的属性上应用过滤器,但GAE不允许我这样做,那么解决方案就是代码片段:

 如果searchParentX:
que.filter(parentX> =,searchParentX).filter(parentX< =,unicode(searchParentX)+ u\\ ('parentX')

如果searchParentY:
que.filter(parentY> =,searchParentY).filter(parentY< ; =,unicode(searchParentY)+ u\\\�)


解决方案

在解决方案将是在存储器中的过滤做一个:




  1. 可以运行两个查询(上一个属性过滤每个)做对结果的交叉点(取决于数据的大小,可能需要将搜索结果限制为一个查询而不是其他,因此它可以适合在内存中)

  2. 运行一个查询并过滤出内存中的其他属性(在这种情况下,如果您知道这将是有益的该属性将返回更多的过滤列表)

另外,如果您的数据的结构可以将数据分解为设置您可以在该设置上执行相等过滤器并在内存中完成过滤。例如,如果您正在搜索的字符串,但是你知道字符串是固定长度(比如6个字符),你可以创建一个乞讨3/4字符的查找字段。然后,当您需要在此字段上进行搜索时,通过匹配前几个字符来完成搜索,并在内存中完成搜索。又如:搜索整数范围时,如果你能定义范围的共同的分组(说十年了一年,或价格范围),那么你就可以定义范围字段做相等搜索并继续在内存中过滤


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.filter("parentX >=", searchParentX).filter("parentX <=", unicode(searchParentX) + u"\ufffd") 
    que.order('parentX')   

if searchParentY :
    que.filter("parentY >=", searchParentY).filter("parentY <=", unicode(searchParentY) + u"\ufffd") 

解决方案

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

这篇关于BadFilterError:无效过滤器:每个查询只有一个属性可能具有不等式过滤器(&lt; =,&gt; =,&lt;&gt;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆