使用数据存储 (NDB)、搜索 API 或两者来查看数据? [英] Use the Datastore (NDB), the Search API or both for views on data?

查看:21
本文介绍了使用数据存储 (NDB)、搜索 API 或两者来查看数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 CMS 中,使用带排序的常规 NDB 查询检索客户列表.为了允许过滤姓名、公司名称和电子邮件,我创建了几个(有时很多)索引.情况并不理想,但可行.

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.

现在有了(实验性的)搜索 API.它似乎与数据存储区(或 NDB)无关,但我的数据已经在那里了.

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

我想使用全文搜索并同时在多个字段上放置过滤器,所以我应该将数据保留在数据存储区中并在文档中复制部分数据以供搜索 API 使用吗?或者,如搜索示例所建议的,请跳过完全数据存储.

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.

推荐答案

我不太确定推荐的实现方法是什么,但 Search API 似乎主要用作额外的、手动管理的索引.在大多数情况下,将您的所有数据存储在 Search API 中并不理想,因为您可以轻松地用不需要过滤或搜索的字段来超出搜索 API 索引的大小,而且它的设计也不是很好地用于需要定期写入的情况.

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.

我个人的建议是将所有数据保留在 NDB 中,并设计类以使用 Search API 创建包含相关可搜索数据的文档,通过在每次写入时更新 Search API 版本来保持两种媒体之间的一致性到数据存储版本(或使用任务/crons 或类似系统,如果您要写入大量数据).在搜索 API 文档中过滤相关数据时,您应该存储您在 UI 中显示的任何数据,因为手动加入搜索 API 结果和数据存储数据是不必要的密集,并且会严重减慢整个过程.

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.

这篇关于使用数据存储 (NDB)、搜索 API 或两者来查看数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆