如何解析SearchResults列表?

时间:2014-06-23 13:11:58

标签: python google-app-engine

我正在使用App Engine搜索API,而我正在尝试提取doc_ids列表。以下是我的查询结果:

search.SearchResults(results=[
    search.ScoredDocument(doc_id=u'-8853541246119947279', rank=0), 
    search.ScoredDocument(doc_id=u'-8853541246119948097', rank=0), 
    search.ScoredDocument(doc_id=u'-8853541246119946461', rank=0),      
    search.ScoredDocument(doc_id=u'51713103325273223', rank=0), 
    search.ScoredDocument(doc_id=u'5587798675278816831', rank=0), 
    search.ScoredDocument(doc_id=u'-8853541246119946464', rank=0), 
    search.ScoredDocument(doc_id=u'-3372400065395745350', rank=0), 
    search.ScoredDocument(doc_id=u'5587798675278815364', rank=0)
], number_found=8L)

如何将doc_id作为列表提取?

1 个答案:

答案 0 :(得分:0)

仔细阅读文件:

results = index.search(search.Query(
            #query and options here, including ids_only=True
            ))
doc_ids = [tmp_result.doc_id for tmp_result in results]