Search code examples
sqlgoogle-cloud-platformgoogle-cloud-spanner

Full text search in Google's Cloud Spanner


Does Cloud Spanner support the CONTAINS method or is there a better way to do a full text search on a string?

In the docs I've found REGEXP_CONTAINS; is this an alternative?


Solution

  • Rather than CONTAINS, the operator you are looking for is LIKE.

    REGEXP_CONTAINS is also definitely a method to achieve text search in Cloud Spanner. It allows you to specify regular expressions (supported by the re2 library).

    You may also want to consider STARTS_WITH and ENDS_WITH if you only want to do prefix or suffix text matching, or STRPOS for simple text matching anywhere.