擅长:python、mysql、java
<p>如果确实需要索引中的每个文档,而不是查询中的每个结果<a href="https://cloud.google.com/appengine/docs/python/search/#Python_Deleting_documents_from_an_index" rel="nofollow">https://cloud.google.com/appengine/docs/python/search/#Python_Deleting_documents_from_an_index</a>,那么可以自定义delete all示例</p>
<pre><code>from google.appengine.api import search
def delete_all_in_index(index_name):
"""Delete all the docs in the given index."""
doc_index = search.Index(name=index_name)
# looping because get_range by default returns up to 100 documents at a time
while True:
# Get a list of documents populating only the doc_id field and extract the ids.
document_ids = [document.doc_id
for document in doc_index.get_range(ids_only=True)]
if not document_ids:
break
# Delete the documents for the given ids from the Index.
doc_index.delete(document_ids)
</code></pre>
<p>所以你可能会得到这样的结果:</p>
^{pr2}$
<p>您可能希望在列表理解中获取文档本身,而不是先获取ID,然后再从该ID中获取文档,但是您得到了想法。在</p>