Elasticsearch における boolean フィールドの処理

Published at: 2023/2/13


Elasticsearch (の mapping) にて boolean を指定した場合に、 Elasticsearch の内部ではこれがどのように処理されているのかについて調べた際のメモ。

Storing booleans as '0' and '1' - Elasticsearch - Discuss the Elastic Stack

Hi, I want to store booleans as '1's and '0's. Is this possible? I've tried storing them as strings but elasticsearch infered they were boolean value. Thanks

discuss.elastic.co

Under the hood, booleans are stored as 1-char bytes in Lucene, so nothing to do there.

boolean フィールドは、内部では 1 byte char に変換されて Lucene index に載せられている、という記述から、例えば tf の文字列に Elasticsearch 側で変換し、それでもって keyword アナライザーで index されているようなもの、と解釈して良さそう。


Tags: elasticsearch