w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python App Engine Full Text Search > empty search return all documents of a search.Index

For instance (untested and very not optimum):

from google.appengine.api import search
...
def get_all_in_index(index_name):
    """Get all the docs in the given index."""
    results = []
    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
        # Get the documents for the given ids from the Index.
        results.append(doc_index.get_range(document_ids))




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.