typesense / typesense/typesense-js
SearchResponseRequestParams doesn't match with actual API response
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 569
- Forks
- 99
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 2
Description
When performing a multiSearch (union) on two collections, I get the following response:
{
"found": 131,
"hits": [ ],
"etc": { },
"union_request_params": [
{
"collection": "collection_one",
"first_q": "test",
"found": 30
"per_page": 18
"q": "test"
},
{
"collection": "collection_two",
"first_q": "test",
"found": 101
"per_page": 18
"q": "test"
}
]
}
However, when looking at the SearchResponseRequestParams-type, it expects the following:
export interface SearchResponseRequestParams {
collection_name?: string;
q?: string;
page?: number;
per_page?: number;
first_q?: string;
voice_query?: {
transcribed_query?: string;
};
}
The collection_name does not match with the actual collection-property, thus my typing is now broken.
More context
Request:
const searchRequests: MultiSearchRequestsWithUnionSchema<
Array<CollectionOneResult | CollectionTwoResult>,
string
> = {
union: true,
searches: [
{
collection: `CollectionOne`,
q: "test",
query_by: "title,content,intro",
filter_by: "_level:0",
},
{
collection: `CollectionTwo`,
q: "test",
query_by: "title,review,description",
filter_by: "_level:0",
},
],
};
const commonParams = {
limit: 18,
page: 1,
};
// Perform the actual query
const results = await client.multiSearch.perform<
Array<CollectionOneResult | CollectionTwoResult>,
string
>(searchRequests, commonParams);
// This line breaks
const collections = results?.union_request_params?.map((req) => req.collection); // Expects collection_name
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SearchResponseRequestParams type and the result returned by multiSearch.perform, then compare union_request_params with the API response shown in the issue. Done means the response type represents the returned collection property and the example access to req.collection type-checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100