tomwalder / php-gds

Google Cloud Datastore Library for PHP
Apache License 2.0
164 stars 44 forks source link

Please add GQL support for "CONTAINS" #118

Open nigeljohnson73 opened 8 years ago

nigeljohnson73 commented 8 years ago

It seems to be supported in the google docs:

https://cloud.google.com/datastore/docs/apis/gql/gql_reference#grammar

Extremely helpful for doing "like" searches.

tomwalder commented 8 years ago

If you read that page further down, you will see that CONTAINS is not for strings. It is for array-like sets and is synonymous with = queries.

Comparators are either equivalence comparators: =, IN, CONTAINS,...

nigeljohnson73 commented 8 years ago

I didn't read that bit that way, sorry. Someone did point me at adding some form of filtering to do "like" styled queries with the full-text-search, but it seems that has not made the PHP API yet. I think there is also a significant overhead with this in both index storage requirements and processing, so probably not a good thing to add to to a cloud project.

I think "contains" would still be a good enhancement for "tag" style fields?

tomwalder commented 8 years ago

You can just use =

For example, if you have a multi-value property (string list) called tags, you can do

SELECT * FROM Books WHERE tags = @tag

and then bind a string like Horror to this, and it will get you any booked tagged as Horror

netcell commented 8 years ago

How can I define a string list field? Do you mean = equals contains and if I have a tags of Horror, Comedy the query would find it too?