Appengine Search API vs Datastore

后端 未结 4 1961
慢半拍i
慢半拍i 2020-12-28 15:55

I am trying to decide whether I should use App-engine Search API or Datastore for an App-engine Connected Android Project. The only distinction that the google documentation

相关标签:
4条回答
  • 2020-12-28 16:13

    The key difference is that with the Datastore you cannot search inside entities. If you have a book called "War and peace", you cannot find it if a user types "war peace" in a search box. The same with reviews, etc. Therefore, it's not really an option for you.

    0 讨论(0)
  • 2020-12-28 16:17

    The Datastore only provides a few query operators (=, !=, <, >), doing nested filters and multiple inequalities would either be costly or impossible (timeouts) and search results may give a lot of False Positives. You can do partial string search by tokenizing but this will bloat your entity. Best way to get through these limitations is using Structured Properties and/or Ancestor Queries.

    Search API on the other hand runs a Full Text search on Search Documents, which is faster and more accurate than NDB queries without relying on tokenized data. Downside is it relies on data staying up to date.

    Use Datastore to process your data (create, update, delete), then run a function to put these data as documents and cluster using indexes, then run the searches using the Search API.

    0 讨论(0)
  • 2020-12-28 16:31

    The most serious con of Search API is Eventual Consistency as stated here: https://developers.google.com/appengine/docs/java/search/#Java_Consistency

    It means that when you add or update a record with Search API, it may not reflect the change immediately. Imagine a case where a user upload a book or update his account setting, and nothing changes because the change hasn't gone to all servers yet.

    I think Search API is only good for one thing: Search. It basically acts as a search engine for your data in Datastore.

    So my advice is to keep the data in datastore that user expects immediate result, and use Search API to search the data that user won't expect immediate result.

    0 讨论(0)
  • 2020-12-28 16:32

    Some other info:

    1. The datastore is a transactional system, which is important in many use cases. The search API is not. For example, you can't put and delete and document in a search index in a single transaction.
    2. The datastore has a lot in common with a NoSql DB like Cassandra, while the search API is really a textual search engine, very similar to something like Lucene. If you understand how a reverse index works, you'll get a better understanding of how the search API works.
    3. A very good reason to combine usage of the datastore API and the search API is that the datastore makes it very difficult to do some types of queries (e.g. free text queries, geospatial queries) that the search API handles very easily. Thus, you could store your main entities in the datastore, but then use the search API if you need to search in ways the datastore doesn't allow. Down the road, I think it would be great if the datastore and search API were more tightly integrated, for example by letting you do free text search against indexed Text fields, where app engine would automatically create a search Document Index behind the scenes for you.
    0 讨论(0)
提交回复
热议问题