【问题标题】:App Engine return more than 20 full text search resultsApp Engine 返回 20 多个全文搜索结果
【发布时间】:2013-10-05 08:02:52
【问题描述】:

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

我可以看到应该使用cursor class,但我不确定如何调整上面的查询以在光标存在时连续循环。

编辑:

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

【问题讨论】:

    标签: google-app-engine cursor gae-search


    【解决方案1】:

    This answer 帮助我想出了以下解决方案:

    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) 
    

    【讨论】:

      猜你喜欢
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      • 2015-05-11
      • 2019-08-20
      • 2015-09-18
      相关资源
      最近更新 更多