0
votes

I want to perform full text search on entities in Google Cloud Datastore using Python 3. This is something very similar to the 'Search API' of GAE but that's for Python 2.7. So, how do I go about this using Python 3.7? Another option is to use Search-as-a-service products like ElasticSearch for which we need to fire up a Compute Engine instance which seems relatively expensive and complicated. So, I was wondering if anyone could help me in finding something as simple as "Search API" for Python 3.7.

Thanks, in advance.

1

1 Answers

2
votes

First of all you should note that the 'Search API' is NOT the same thing (or even related) with a datastore search.

In the search API creating and maintaining a document index (which is not a datastore index) is programmatic, performed at runtime and entirely the responsibility of the application. That index is what allows the full-text (and partial text) searches to be performed.

The datastore indexes must be created before they can be used by the application at runtime. Maintaining the index is done by the datastore, as entities are being added/deleted/modified. Only entire/complete property values are present in the index and these entire values must be specified when performing searches (partial values won't work). Only string values up to 1500 bytes in length can be indexed, longer strings cannot.

The only official suggestion comes from a flexible environment guide (similarly missing the Search API support) which is what you probably saw:

The Search service is currently unavailable outside of the standard environment. You can host any full-text search database such as ElasticSearch on Google Compute Engine and access it from both the standard and flexible environments.

You could write your own app to implement capabilities similar to the Search API (using the datastore under the hood). The capabilities are described in more detail in Search API Basics.