Chloe
Chloe

Reputation: 26264

Google AppEngine Search API only returns 20 results, even though there are more

When I search the AppEngine Search API, it is only returning 20 results, even though I have 68 items in the index. The reference documentation says it can return up to 10,000 results. How do I return more results?

Code

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;
}

Log

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

Index

Imgur

Version

appengine-api-1.0-sdk-1.8.6.jar

Reference

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

Upvotes: 1

Views: 388

Answers (1)

musketyr
musketyr

Reputation: 828

I guess the number of items in the results has some default pagination. The number you're looking for is getNumberFound() which should contain the expected number of results satisfying the query.

Upvotes: 1

Related Questions