-
Notifications
You must be signed in to change notification settings - Fork 21
client.search should take parameters as object, but send as string #528
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
Comments
Thanks! Do you know if it's also the case with other clients? |
Also, it seems to only be for this endpoint, right? The |
see an example encoded string from v4: https://codesandbox.io/s/y05j5kyolj?file=/src/decode.js in v4 it's done using serializeQueryParameters: |
Yep we do have that logic in place too but not at this level for this method |
yes, singleIndexSearch doesn't have params, the options are json top-level (verified in https://codesandbox.io/s/gallant-hofstadter-v4ps0v?file=/src/app.js) |
Actually that made me think, and the engine already accepts this (no scoping of params): const { results } = await client.search({
requests: [
{
type: 'default',
indexName: 'instant_search',
query: 'hi',
hitsPerPage: 1,
analyticsTags: ['search!!'],
},
{
type: 'facet',
indexName: 'instant_search',
facet: 'brand',
facetQuery: 'app',
hitsPerPage: 1,
analyticsTags: ['facet'],
},
],
}); |
I don't know how to express that in specs, but the correct type is: import type { SearchParamsObject } from './searchParamsObject';
export type SearchQueries = SearchParamsObject &
(
| {
type: 'facet';
indexName: string;
facet: string;
facetQuery?: string;
}
| {
type?: 'default';
indexName: string;
}
); PS. this type should be called SearchQuery, not SearchQueries, as it's a single object |
Can you open a second issue for #528 (comment) 😇 ? So we can tackle both and make tickets :D |
I think the original issue doesn't need to be solved if #528 (comment) or #529 approach is chosen. That way the parameters are
|
Uh oh!
There was an error while loading. Please reload this page.
Description
Steps to reproduce
searchClient.search
{ requests: [{ indexName: "abc", params: { query: 'something', hitsPerPage: 2 }}]}
Expected behavior
it should have turned the
params
intoparams: "query=something&hitsPerPage=2"
I think some search parameters are more than one level, but then don't get transformed further, just encoded and escaped
Environment
The text was updated successfully, but these errors were encountered: