-
Notifications
You must be signed in to change notification settings - Fork 90
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
User should be able to drop a pending search request - Discussion #630
Comments
I like your idea. We use I'm not sure I understand your solution proposal. What is "..." ? |
I just run into the same issue, so I've prepared a PR ( #636 ) that allows the user to add another configuration directly to the search request, e.g., So, the request can be aborted like this: const controller = new AbortController()
const searchPromise = client.getIndex('movies').search('query', {}, 'GET', {
signal: controller.signal,
});
controller.abort()
try {
await searchPromise(); // throws AbortError
} catch (e) {} Maybe in the future, it would be nice to have a mechanism that automatically aborts the previous search request, or returns something like this "Abortable fetch". |
I don't bring any solution, but just my experience with InstantSearch + meilisearch-js (via instant-meilisearch) I don't have any issue, InstantSearch handles perfectly the requests order:
Maybe we can check how InstantSearch handles it. |
When implementing a type-as-you-search experience, IMHO, the best experience comes from sending a search request immediately as the user types / modifies the input in the search bar. This implementation gives you some results as quick as it can, but it can be complicated in some contexts because multiple search requests can be running at the same time, and treating the responses can lead to a slow experience or to wrong results caused by the order in which those requests are sent.
Most workarounds must be implemented by the front-end developer, ignoring the requests that he/she doesn't want to show (but still using resources), doing an implementation which lets him/her cancel the pending requests, or worse, this can lead to introducing bugs or showing worng results!
Example:
a user searchs "cost"
Sometimes request # 4 could be treated by MeiliSearch faster than # 3, and the front-end client will receive # 4's response and show it to the user, then receive # 3's answer and show it to the user. This leads to showing the user the results of "cos" but he wanted the results of "cost", an so it displays worng results.
In several cases a lot of requests shoudln't even be treated at all, or preferably, dropped.
Simple example of solution
A single example on how to solve this from the client side, it the method
.abort()
in AJAX.when you do an
XMLHttpRequest
, this request can be dropped at anytime:but we are not using AJAX so...
Proposition
Implement a method that exposes to the user the posibility of droping/aborting a search request.
More info or ideas on how to do it in this article
WDYT?
@curquiza @bidoubiwa @tpayet
The text was updated successfully, but these errors were encountered: