Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting AppEngine Datastore and Search API

I wonder what the best way is to connect the Datastore and the Search API.

What I'm looking for is whenever I create some entity (e.g. a product) that this product will be added to a search index. On update the index should be updated as well, and when deleting the product - you guess right - the product should be removed from search index.

When searching for a product I want to do a full-text search on the product index, but instead of the documents I need the real entities. Probably I will need to first search using the index, and then do a second call to the datastore?

What worries me most is keeping the datastore and search index in synch. And of course also going through the search index and the datastore will not only be cumbersome but I feel it might also give pains in terms of pagination.

I wonder if some people already have "connected" the datastore and search api this way and what the results have been, and maybe some best practices available. The appengine docs are not telling much is this area.

like image 547
Marcel Overdijk Avatar asked Nov 15 '12 12:11

Marcel Overdijk


People also ask

What is Datastore API?

Jetpack DataStore is a data storage solution that allows you to store key-value pairs or typed objects with protocol buffers. DataStore uses Kotlin coroutines and Flow to store data asynchronously, consistently, and transactionally.


1 Answers

In order to user the Search API, you need to define your searchable data into documents, and then structure them into an index by using the Index class. Thus, for the time being you need to do exactly what you describe, keep in sync the searchable documents with your datastore entities.

like image 79
Thanos Makris Avatar answered Oct 19 '22 23:10

Thanos Makris