Google AppEngine Search API仅返回20个结果,即使还有更多结果

时间:2013-12-03 23:06:26

标签: java google-app-engine google-search-api

当我搜索AppEngine Search API时,它只返回20个结果,即使我在索引中有68个项目。参考文档说它最多可以返回10,000个结果。如何返回更多结果?

代码

public Results<ScoredDocument> search(String q) {
    log.severe("Searching with query: " + q);
    try {
        Results<ScoredDocument> results = getIndex().search(q);
        log.severe("results.size:"+results.getNumberReturned());

public Index getIndex() {
    IndexSpec indexSpec = IndexSpec.newBuilder().setName("OnixIndex").build(); 
    Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec);
    return index;
}

日志

E 2013-12-03 17:55:49.858
com.mwv.pic.service.SearchService search: Searching with query: 
E 2013-12-03 17:55:51.446
com.mwv.pic.service.SearchService search: results.size:20

索引

Imgur

版本

应用服务引擎的API-1.0-SDK-1.8.6.jar

参考

https://developers.google.com/appengine/docs/java/search/

1 个答案:

答案 0 :(得分:1)

我猜结果中的项目数有一些默认分页。您要查找的数字是getNumberFound(),其中应包含满足查询的预期结果数。