typesense / typesense-js

JavaScript / TypeScript client for Typesense
https://typesense.org/docs/api
Apache License 2.0
400 stars 74 forks source link

MultiSearch: multiSearch.perform types #160

Closed ycouble closed 1 year ago

ycouble commented 1 year ago

Change Summary

Usage would be :

type Employee = {name: string}
type Company = {orgName: string}

res = await client.multiSearch.perform<[Employee, Company]>(
  [
    {q, query_by: "name", collection: "employees"},
    {q, query_by: "orgName", collection: "companies"}
  ]
)
[employees, companies] = res.results
# type of employees : Employee
# type of companies : Company

PR Checklist

jasonbosco commented 1 year ago

Thank you @ycouble!

jasonbosco commented 1 year ago

I've published this in v1.6.0-0. Could you give it a try?

ycouble commented 1 year ago

Works perfectly ! Thanks for the quick integration !


const response = await client.multiSearch.perform<[IndexedLocation, IndexedAddress, IndexedCommune]>({
    searches: [poiSearchParams, addressSearchParams, citySearchParams],
  }, {
    per_page: 10,
  });```
jasonbosco commented 1 year ago

Thank you for confirming and thank you for the PR!