Implement placeholder search. Update tests #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About this PR:
As defined in meilisearch/meilisearch#771, MeiliSearch will implement placeholder search starting with v0.13.0
A search request containing no Query parameter (or a null value in that parameter) will send a response with a basic placeholder search showing ranked results, and will be as customizable as any other search request.
GO types and default initialization to zero value doesn't let us make a clear distinction between an uninitialized String (some
nil
value) and an empty String (some""
value) when all we are handling is a string. We need to be able to provide those two options in order to implement placeholder search, which expects noq
parameter (no query) or a null value.An option to do this would be using a string pointer that can be uninitialized (nil), contain an empty string, or contain a valid string. The problem with this is that it would add some unnecessary complexity to the whole search experience, as the user would need to always use pointers towards a string to perform the search. So adding a new functionnality results in making search experience work.
The most practical solution to this from my POV is to add a boolean value to the SearchRequest struct where the user indicates if he wants to perform a placeholder search. This won't be breaking, completey optional, and really simple to use.It can work as in:
Which would return the placeholder search results, and would be clearly different than
if
PlaceholderSearch
is set to true,Query
will be totally ignored for that requestWhich would return no results
Closes #69