0

I am using python 2.7, jinja2 and google app engine.

I have a database where one of the entities are string in this form:

"test1,test2,test3,test4,test5"

I try to figure a query where I will retrieve all the entities where test1 for example are in the string.

I tried the following where tags is the string property:

category = "test1"
mymodel.gql("WHERE tags in :1", category)

I have this error : BadArgumentError: List expected for "IN" filter

I can imagine that this is logical, since my property is string and not list, but how can I change the query to make it work?

Tasos
  • 7,325
  • 18
  • 83
  • 176

2 Answers2

0

As the error indicates, the GQL is expecting a list. Try making category a list:

category = ["test1"]
Brent Washburne
  • 12,904
  • 4
  • 60
  • 82
  • Unfortunately that doesn't help. I don't have an error any more, but the query is empty. – Tasos Jun 07 '13 at 22:24
  • That's because GQL doesn't perform Full Text searches, see http://stackoverflow.com/questions/47786/google-app-engine-is-it-possible-to-do-a-gql-like-query – Brent Washburne Jun 07 '13 at 22:48
0

You would have to modify you property to be a StringListProperty rather than string for this to work.

There are not a lot of other choices either. Use FullText Search is or something like WHoosh https://github.com/tallstreet/Whoosh-AppEngine which also does full text search are your other alternatives.

I would personally change it to a StringListProperty.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29