Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit_hits doesn't work #181

Open
justin5267 opened this issue Aug 19, 2023 · 4 comments
Open

limit_hits doesn't work #181

justin5267 opened this issue Aug 19, 2023 · 4 comments

Comments

@justin5267
Copy link

justin5267 commented Aug 19, 2023

Description

I've configured the limit_hits, but it doesn't work,still returning all hits.

Steps to reproduce

I'm using instantsearch.js, and all other parameters are functioning correctly.

Expected Behavior

rutrun limited hits

Actual Behavior

return all the hits

Metadata

Typesense Version:0.25
typesense-instantsearch-adapter Version:2.7.1

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
server: {
apiKey: "XXX",
nodes: [
{
host: "XXX",
port: "443",
protocol: "https",
},
],
cacheSearchResultsForSeconds: 2 * 60,
},

additionalSearchParameters: {
	num_typos: 0,
	drop_tokens_threshold: 0,
	typo_tokens_threshold: 0,
	per_page: 50,
	limit_hits:200,
	highlight_affix_num_tokens: 30,
	query_by: "content",
	facet_by: "XXX",
	sort_by: "XX"
},

});

@justin5267 justin5267 changed the title limit_hits not work limit_hits doesn't work Aug 19, 2023
@jasonbosco
Copy link
Member

Could you open the browser's network tab, then do an action that triggers the search, then open that request in the network tab, copy both the request parameters and the response from Typesense and paste it here?

@justin5267
Copy link
Author

justin5267 commented Aug 21, 2023

Thanks a lot,the request parameters and the response are as follows:

@jasonbosco
Copy link
Member

Ah, I think there might be a misunderstanding about what limit_hits does... It's meant to control the total number of hits that can be retrieved via pagination. So for eg, since you've set limit_hits to 2000, even though 2758 results were found, if you try to fetch the 2001th record via pagination, Typesense will throw an error.

So limit_hits is meant mainly for protecting against someone scraping all results in your dataset. This is also why you'd want to use limit_hits embedded inside a Scoped Search API key, so it cannot be modified by a malicious actor on the client side.

@justin5267
Copy link
Author

justin5267 commented Aug 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants