Skip to content

Is it possible to get the exact number of hits? #1264

Answered by joemcelroy
dkalpakchi asked this question in Q&A
Discussion options

You must be logged in to vote

hi there!

Its possible but you need to use beforeSearch request hook instead to pass in track_total_hits to each request.

The difference between getQuery and beforeSearch hooks is that beforeSearch allows you to modify the whole request. getQuery` is for those who want to adjust only the relevance of the organic query.

https://www.searchkit.co/docs/api-documentation/searchkit#beforesearch-hook-function

Something like

client = SearchkitInstantsearchClient(sk, {
    hooks: {
        beforeSearch: async (searchRequests) => {

            return searchRequests.map((sr) => {
                return {
                  ...sr,
                  body: {
                    ...sr.body,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dkalpakchi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants