algolia / algoliasearch-client-java-legacy

*DEPRECATED* Algolia Search API Client for Java, see https://github.com/algolia/algoliasearch-client-java-2
MIT License
31 stars 16 forks source link

nbPages returned from API is incorrect #12

Closed nikhil-bhandari closed 9 years ago

nikhil-bhandari commented 9 years ago

I am querying my index using JAVA client and I have set [hitsPerPage : 1000 , page: 0]. The response that gets returned says that nbHits is 7572 but nbPages is 1.

My problem is not restricted to nbPages now if I set page to 1 and hitsPerPage to 1000 nothing gets returned but nbHits is still 7572. Also if I set hitsPerPage to 1, I get nbPages as 1000 in response.

Is there a known issue or am I missing something here?

Sample API response:

{
    "query": "",
    "timeoutHits": false,
    "facets": {...}
    "processingTimeMS": 66,
    "params": "getRankingInfo=1&page=0&hitsPerPage=1000....",
    "parsedQuery": "",
    "hitsPerPage": 1000,
    "nbPages": 1,
    "exhaustiveFacetsCount": false,
    "timeoutCounts": false,
    "hits": 0,
    "page": 0,
    "nbHits": 7572,
    "facets_stats": {...},
    "serverUsed": "***************"
}
Nagriar commented 9 years ago

Hi @nikhil-bhandari,

For performance reason, there's a limit of 1000 hits for this method, that's why you have only one page with a hits per page at 1000.

if you want to retrieve more than 1000 hits, you can have a look at the browse method: https://github.com/algolia/algoliasearch-client-java#backup--retrieve-of-all-index-content

You'll be able to retrieve the complete list of the results and you can pass the same query parameter than the search method but the relevance will be lower because we don't apply sort on the number of typo, matched words, geo distance and proximity.

Regards,

nikhil-bhandari commented 9 years ago

Ok so you mean I cannot paginate more than 1000 results?

nikhil-bhandari commented 9 years ago

I tried using browse method but had to revert it as it doesn't return the ranking info and I have to support a legacy API that uses the score.

redox commented 9 years ago

I tried using browse method but had to revert it as it doesn't return the ranking info and I have to support a legacy API that uses the score.

What do you mean by legacy API? Do you want you to sort the results returned by the browse method yourself?

nikhil-bhandari commented 9 years ago

Nope score wasn't need for sorting. Score was actually something that elastic search returned to us and we were passing it on further to our API consumers. I confirmed with them and they are not using it, so score is not an issue now.

But some other pages in my app are broken now.

We were using elastic search in admin panel for faster searching of records and we simply changed them to Algolia and removed ES completely. Now the user list page breaks when we reach page 1000 (max 10 , offset 1000) because no result get's returned.

And this is not the only page there are many such pages that break because we don't have records to show there.

@Nagriar mentioned that For performance reason the limit is set to 1000 but a few weeks back someone on live chat said that its to prevent scraping. If its for scraping then browse method can still give a complete dump easily.

nikhil-bhandari commented 9 years ago

I think browse will work for me, so I'm closing this issue.