Search code examples
searchplayframeworksiena

How does siena query search work?


I'm looking for a documentation on how to do a query in siena that returns all the elements which contains a string. I tried something like

return all().search("nome", query).fetch();

but it returns all the elements, with no filtering.


Solution

  • Sorry for the delay, I wasn't available!
    You use GAE, isn't it?
    Siena Search for GAE is very limited as GAE provides very limited search features for its datastore. So Siena implements what it can using some tricks.

    In a summary:

    Siena ALLOWS the following searches for GAE (for the time being):

    • search on 1 field and no more: all().search("the_string_to_search", "the_field_to_search").fetch()

    • search on field equaling one precise string: all().search("myString", "the_field_to_search").fetch()

    • search on field equaling several precise strings (like a OR): all().search("myString1 myString2", "the_field_to_search").fetch()

    • search on field beginning with a string: all().search("myString*", "the_field_to_search").fetch()

    Siena DOESN'T ALLOW the following searches for GAE:

    • search on several fields: all().search("myString", "field1", "field2").fetch() GENERATES EXCEPTION

    • search on field ending with a string: all().search("*myString", "the_field_to_search").fetch() GENERATES EXCEPTION