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
  • 6,330
  • 10
  • 64
  • 148

2 Answers2

0

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

category = ["test1"]
Brent Washburne
  • 11,417
  • 4
  • 51
  • 70
  • 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,908
  • 1
  • 15
  • 28