Enterprise Search in Japanese: Why We Switched from Kuromoji to N-gram


The Problem: “Search Results Are Wrong”

On a project, a client came to us with a complaint:

“The search results don’t make sense.”

Results were showing up that didn’t match the search terms.


Context

At this point, I already knew this would be tricky.


Root Cause: Kuromoji

After investigation, the cause was straightforward.

👉 They were using Kuromoji.

Kuromoji is a morphological analyzer, which means:

In other words:

👉 It’s built for “text comprehension,” not “search”


What Was Happening

For example, even when the search term was an exact match:

The result:

👉 “Why is this showing up?” 👉 “Why isn’t this showing up?”


Kuromoji is powerful, but:

👉 It’s not suited for general search (partial match, fuzzy search)

Especially in enterprise systems, users expect:

Kuromoji doesn’t deliver that.


Solution: Switch to N-gram

The fix was simple:

👉 Switch to n-gram

This gave us:


The Real Challenge

Since this was ElasticSearch:

👉 Changing the analyzer = full reindex required

That means:


Zero-Downtime Release with Aliases

The technique we used:

👉 Index aliases

Here’s the process:

  1. Create a new index (with n-gram analyzer)
  2. Reindex the data
  3. Verify behavior in advance
  4. Switch the alias

👉 The actual release takes a split second


Why This Matters

With this approach:


Summary


One Takeaway

👉 Japanese enterprise search is 90% decided by your technology choice


Side Note (From Experience)

Kuromoji is powerful when you understand it properly.

But if you just default to “it’s Japanese, so use Kuromoji” — things will break.