App Engine返回20多个全文搜索结果

时间:2022-09-10 19:22:23

I need to loop through the maximum amount of full text search results with Python App Engine SDK. My code is currently as follows:

我需要使用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)

I can see the cursor class should be employed, though I'm not sure how to adjust my above query to continuously loop while a cursor exists.

我可以看到应该使用游标类,虽然我不确定如何调整我的上述查询以在游标存在时连续循环。

EDIT:

Based on my current data size, I don't expect to need to loop more than a few times, so it should stay within GAE process timeout limits.

根据我当前的数据大小,我不希望循环超过几次,因此它应该保持在GAE过程超时限制内。

1 个解决方案

#1


0  

This answer helped me to come up with the following solution:

这个答案帮助我提出了以下解决方案:

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) 

#1


0  

This answer helped me to come up with the following solution:

这个答案帮助我提出了以下解决方案:

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)