For CJK language, the request mechanism is exponentially wasted

CJK using IME requires typing n letters to successfully type a CJK character or word, which is what the user wants to search. However, the current request mechanism, which sends a request for each letter as it is typed, wastes the request amount bye-bye.

For example, when I want to type a Chinese word “博客” (which means blog in English), I need to type the following letters in IME: b-o-k-e, and after that is done, I will press the space bar to finish the final input of “博客”. Algolia executed 5 requests during this time, and only the last one was useful.

2022-07-16_11-47-10 (1)

It is recommended to check if you are in an IME environment, and if so, to start sending requests after the final input.

I’m currently not sure if Algolia already has a solution for this, I just don’t know.

I’m not sure, what is the biggest technical difficulty with this? The request resources are being wasted and the cost of it is not worth it for Algolia or the user.

Hi @kmt007,

Thanks for the feedback on IME-based character entry. While we don’t have a ready-made solution for this use case, you could build a workaround using tools available in our front-end libraries.

For example, with InstantSearch.js, you can use queryHook in combination with the isComposing property to listen to changes on the search input and tracking them in some local front-end state based on event.isComposing (indicating they’re in an IME environment). Based on this state, you could then either trigger a search or wait for a user to complete IME character entry.


Thanks a lot, is there a configuration example? I am currently using jekyll-algolia on jekyll and the script code is as follows.

I don’t have an example of this pattern, but here’s a debounce example that might get you started…

Thanks a lot, I added a line, searchOnEnterKeyPressOnly: true, and now it’s perfect.

    container: '#search-searchbar',
    searchOnEnterKeyPressOnly: true,
    placeholder: 'Explore this site...',
    poweredBy: true // This is required if you're on the free Community plan

Oh! It’s a shame you lose “as you type” results – is it just too complex to predict when the IME typing has resolved into a character?


Thanks, I got a lot of help and kindness!

However, not sure what you mean by you lose 'as you type'results? If this means that I only trigger the search request when I finally press enter, then that would be exactly what I want.

For CJK using IME, search as you type is not useful at all, because the language unit of CJK is words, not letters.

In order to enter a CJK character, you need to type in many letters. Searching for these letters and their combinations is pointless and will only cause exponential waste.

I hope there will be good news to improve CJK search in the future.

Finally, I would like to confirm that after adding the parameter searchOnEnterKeyPressOnly: true, will I indeed request a search only after pressing the Enter key?