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
add SearchRaw to return raw JSON from search #377
Conversation
adds a method SearchRaw with the same signature as SearchIndex except it returns json.RawMessage
878a6b4
to
7dbefd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ginglis13 for this PR it will be a really great addition 🚀
I just made a suggestion 😊
req := internalRequest{ | ||
endpoint: "/indexes/" + i.UID + "/search", | ||
method: http.MethodPost, | ||
contentType: contentTypeJSON, | ||
withRequest: searchPostRequestParams, | ||
withResponse: resp, | ||
acceptedStatusCodes: []int{http.StatusOK}, | ||
functionName: "Search", | ||
} | ||
|
||
if err := i.client.executeRequest(req); err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this method can call directly SearchRaw
and Unmarshal the result in SearchResponse
to avoid duplicate code, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah great point... I was essentially doing that in the unit test but not the actual implementation 😅 I'll take your suggestion and make that change
Hi @ginglis13, |
Hi, have you consider just change // SearchResponseRaw is the response body for search method without decoding Hits.
type SearchResponseRaw struct {
Hits []json.RawMessage `json:"hits"`
EstimatedTotalHits int64 `json:"estimatedTotalHits"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
ProcessingTimeMs int64 `json:"processingTimeMs"`
Query string `json:"query"`
FacetDistribution json.RawMessage `json:"facetDistribution,omitempty"`
} |
Yes, but for me, it was simpler to propose a method that returns either a ready object with the existing structure in the SDK or returns a complete object in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @ginglis13 for this PR and the great addition to this SDK 🎉
LGTM! 🔥
Thanks again for contributing with Meilisearch ❤️
If you are participating in Hacktoberfest, and you would like to receive some swag from Meilisearch too, please complete this form.
bors merge |
adds a method SearchRaw with the same signature as Search except it returns json.RawMessage
Pull Request
Related issue
Fixes #337
What does this PR do?
SearchIndexRaw
to index interface as a method to return ajson.RawMessage
from a searchwant
of typeSearchResponse
; this is because to verify the method, the test is unmarshalling the raw response returned into aSearchResponse
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!