Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,28 @@ export default function instantMeiliSearch(hostUrl, apiKey, options = {}) {
},

search: async function (requests) {
// Params got from InstantSearch
const params = requests[0].params
this.pagination = params.page !== undefined // If the pagination widget has been set
this.hitsPerPage = params.hitsPerPage || 20 // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
// Gets information from IS and transforms it for MeiliSearch
const searchInput = this.transformToMeiliSearchParams(params)
const indexUid = requests[0].indexName
// Executes the search with MeiliSearch
const searchResponse = await this.client
.index(indexUid)
.search(searchInput.q, searchInput)
// Parses the MeiliSearch response and returns it for InstantSearch
return this.parseMeiliSearchResponse(
indexUid,
searchResponse,
requests[0].params
)
try {
// Params got from InstantSearch
const params = requests[0].params
this.pagination = params.page !== undefined // If the pagination widget has been set
this.hitsPerPage = params.hitsPerPage || 20 // 20 is the MeiliSearch's default limit value. `hitsPerPage` can be changed with `InsantSearch.configure`.
// Gets information from IS and transforms it for MeiliSearch
const searchInput = this.transformToMeiliSearchParams(params)
const indexUid = requests[0].indexName
// Executes the search with MeiliSearch
const searchResponse = await this.client
.index(indexUid)
.search(searchInput.q, searchInput)
// Parses the MeiliSearch response and returns it for InstantSearch
return await this.parseMeiliSearchResponse(
indexUid,
searchResponse,
requests[0].params
)
} catch (e) {
console.error(e)
throw new Error(e)
}
},
}
}