Implementing “Starts with” and “Ends with” queries with Google App Engine

后端 未结 2 654
不知归路
不知归路 2021-01-03 03:13

Am wondering if anyone can provide some guidance on how I might implement a starts with or ends with query against a Datastore model using Python?

In pseudo code, it

相关标签:
2条回答
  • 2021-01-03 04:07

    Seems you can't do it for the general case, but can do it for prefix searches (starts with):

    Wildcard search on Appengine in python

    0 讨论(0)
  • 2021-01-03 04:08

    You can do a 'starts with' query by using inequality filters:

    MyModel.all().filter('prop >=', prefix).filter('prop <', prefix + u'\ufffd')
    

    Doing an 'ends with' query would require storing the reverse of the string, then applying the same tactic as above.

    0 讨论(0)
提交回复
热议问题