简体   繁体   English

Google Appengine Search API到数据存储区查询

[英]Google Appengine Search API to Datastore Query

I construct the Search API data like 我构建了像这样的Search API数据

search.SearchResults(
results=
[
search.ScoredDocument(doc_id=u'4873035534303232', fields=[search.TextField(name=u'name', value=u'a'), search.TextField(name=u'description', value=u'b'), search.DateField(name=u'date', value=datetime.datetime(2015, 2, 16, 7, 21, 58, 188000)), search.TextField(name=u'author', value=u'test@example.com')], language=u'en', rank=130231318L), 
search.ScoredDocument(doc_id=u'5717460464435200', fields=[search.TextField(name=u'name', value=u'a b c'), search.TextField(name=u'description', value=u'c d e'), search.DateField(name=u'date', value=datetime.datetime(2015, 2, 16, 7, 21, 25, 965000)), search.TextField(name=u'author', value=u'test@example.com')], language=u'en', rank=130231285L), 
search.ScoredDocument(doc_id=u'5506354231902208', fields=[search.TextField(name=u'name', value=u'How about today?'), search.TextField(name=u'description', value=u"it's good"), search.DateField(name=u'date', value=datetime.datetime(2015, 2, 16, 7, 10, 13, 608000)), search.TextField(name=u'author', value=u'test@example.com')], language=u'en', rank=130230613L)
],
number_found=3L)

I didn't insert the blobKey to Search API, then I need to query of Datastore to get the blobKey. 我没有将blobKey插入到Search API中,然后我需要查询Datastore来获取blobKey。 Each ndb article has a same doc_id as a ID. 每个ndb文章都具有与ID相同的doc_id。

So when I get the response of Search API, I have to query 3 times for 因此,当我得到Search API的响应时,我必须查询3次

doc_id=u'4873035534303232', doc_id=u'5717460464435200', doc_id=u'5506354231902208'

I think this process is so bad. 我认为这个过程非常糟糕。 Quota will be exceed soon. 配额将很快超过。 Do you have any other solution? 你有其他解决方案吗?

Use ndb.get_multi or just de-normalize that data and store it in the search API for faster access. 使用ndb.get_multi或者只是对该数据进行反规范化并将其存储在搜索API中以便更快地访问。

ndb.get_multi will use single batch to get all keys and use only N read operations. ndb.get_multi将使用单个批处理来获取所有密钥并仅使用N个读取操作。 (0.05 Million Ops is Free) (0.05百万行动是免费的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM