0

Python App Engine SDK を使用して、最大量の全文検索結果をループする必要があります。私のコードは現在次のとおりです。

search_index = search.Index(name="fullText")
indexed_results = search_index.search(search_query) 
for scored_document in indexed_results:
    hits_from_full_text_search.append(scored_document.doc_id)

カーソルクラスを使用する必要があることがわかりますが、カーソルが存在する間、上記のクエリを継続的にループするように調整する方法はわかりません。

編集:

私の現在のデータ サイズに基づくと、数回以上ループする必要はないと予想されるため、GAE プロセスのタイムアウト制限内にとどまる必要があります。

4

1 に答える 1

0

この回答は、次の解決策を思い付くのに役立ちました。

cursor = search.Cursor()                                          
search_index = search.Index(name="fullText")                      

while cursor != None:                                             

    options = search.QueryOptions(limit=5, cursor=cursor)         
    indexed_results = search_index.search(                        
    search.Query(query_string=search_query, options=options)) 
    cursor=indexed_results.cursor                                 

    for scored_document in indexed_results:                       
        hits_from_full_text_search.append(scored_document.doc_id) 
于 2013-10-05T08:34:09.823 に答える