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

MultiSearch: multiSearch.perform types #160

Merged
merged 1 commit into from
Jun 16, 2023
Merged

Conversation

ycouble
Copy link
Contributor

@ycouble ycouble commented Jun 14, 2023

Change Summary

  • generic type is carried by perform function and not the class
  • type annotation is a tuple of Document schema, and the return type is a mapped tuple of SearchResponse of the specified documentSchema, in the same order

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

- generic type is carried by perform function and not the class
- type annotation is a tuple of Document schema, and the return type is a mapped tuple of SearchResponse of the specified documentSchema, in the same order

Usage would be : 
```typescript
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
# type of employees : Employee
# type of companies : Company
```
@jasonbosco
Copy link
Member

Thank you @ycouble!

@jasonbosco jasonbosco merged commit 893dc6f into typesense:master Jun 16, 2023
@jasonbosco
Copy link
Member

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

@ycouble
Copy link
Contributor Author

ycouble commented Jun 19, 2023

Works perfectly ! Thanks for the quick integration !

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

@jasonbosco
Copy link
Member

Thank you for confirming and thank you for the PR!

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

Successfully merging this pull request may close these issues.

2 participants