# Chinese, Japanese and Korean

Chinese and Japanese do not separate words with spaces, and Korean compounds freely. The `cjk`
analyzer indexes runs of Han, Hiragana, Katakana and Hangul as overlapping two-character pairs, so
`東京都` is indexed as `東京` and `京都`, and a query matches when its pairs appear in that order. It
needs no dictionary. Latin words and numbers in the same text are kept as words.

```json
{"fields": {"title_ja": {"type": "text", "analyzer": "cjk"}}}
```

The chain is `unicode_word`, `cjk_width`, `lowercase`, `cjk_bigram` and the CJK stop words, the
same as Elasticsearch's `cjk` analyzer.

## Filters

| Filter | Does |
|---|---|
| `cjk_width` | Fullwidth ASCII to normal letters and digits (`ＡＢＣ` to `ABC`); halfwidth Katakana to fullwidth. |
| `cjk_bigram` | Overlapping pairs. Params `han`, `hiragana`, `katakana`, `hangul` (all default `true`) choose the scripts to pair; others stay single characters. `output_unigrams` (default `false`) also indexes each character. |

A one-character query matches nothing by default, because only pairs are indexed. Set
`output_unigrams` to `true` to also match single characters, at the cost of a larger index:

```json
{
  "type": "text",
  "analyzer": {
    "tokenizer": "unicode_word",
    "filters": ["cjk_width", "lowercase", {"name": "cjk_bigram", "params": {"output_unigrams": true}}]
  }
}
```

## Tips

- Pairs match more than words do: a query for `京都` (Kyoto) also finds `東京都` (Tokyo
  Metropolis), which contains the same pair. Phrase queries and BM25 ranking keep the best
  matches on top.
- `icu_tokenizer` is the alternative: it splits Chinese and Japanese into dictionary words
  instead of pairs, which gives a smaller index and fewer partial matches, but misses words the
  dictionary splits differently. See [Multilingual text and ICU](icu.md).
- Elasticsearch's `cjk` analyzer, the `cjk_width` and `cjk_bigram` filters and Solr's `text_cjk`
  type map to these components. See
  [Through the compatible APIs](text-analysis.md#through-the-compatible-apis).
