Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use the Datastore (NDB), the Search API or both for views on data?

In a CMS, a list of customers is retrieved using a regular NDB query with ordering. To allow filtering on name, company name and email, I create several (sometimes many) indices. The situation was not ideal, but workable.

Now there's the (experimental) Search API. It seems to have no relation to the datastore (or NDB), but my data is already there.

I'd like to use Full Text Search and put filters on multiple fields simultaniously, so should I keep my data in the Datastore and duplicate parts of the data in Documents for the Search API? Or, as the search example suggests, skip the Datastore entirely.

like image 604
kvdb Avatar asked Oct 28 '12 19:10

kvdb


People also ask

What is NDB in app Engine?

App Engine NDB enables Python 2 apps to store and query data in Firestore in Datastore mode (Datastore) databases. Cloud NDB enables Python 2 and Python 3 apps to store and query data in the same databases and uses Datastore as the product that manages those databases.

What is NDB Python?

The Google Datastore NDB Client Library allows App Engine Python apps to connect to Datastore. The NDB client library builds on the older DB Datastore library adding the following data store features: The StructuredProperty class, which allows entities to have nested structure.


1 Answers

I'm not quite sure what the recommended method is for its implementation, but the Search API seems designed to be utilized primarily as an additional, manually managed index. Its not ideal in most situations to store all of your data in the Search API, as you can easily blow out the size of the search API indexes with fields which you never need to filter or search, nor is it well designed to be utilized in situation where regular writes are necessary.

My personal recommendation is to leave all of your data in NDB, and design classes to create documents containing the relevant searchable data using the Search API, maintaining consistency between the two medium's by updating the Search API version each time a write is made to the datastore version (or using tasks/crons or a similar system if you're writing data a lot). You should store any data you present in the UI when filtering in the Search API documents for that related data, as manually joining the search API results and the datastore data is unnecessarily intensive, and will severely slow down the whole process.

like image 163
Twistieman Avatar answered Nov 05 '22 07:11

Twistieman