Elasticsearch boolean型にfieldsが指定できない
メモ程度。
ElasticsearchのMappingでfieldsというのがある。
Multi fieldsがなくなりこちらの形式になったとのことだが
{ "tweet" : { "properties" : { "name" : { "type" : "string", "index" : "analyzed", "fields" : { "untouched" : {"type" : "string", "index" : "not_analyzed"} } } } } }
こんな形で1つのフィールドに複数のindexが指定できる。
sortするときとかはnot_analyzed
にたいしてやったりする。
これをbooleanでやろうとしたときのお話。
古いバージョンでmulti_fieldsを使用していて、アップデートしたときは
{ "tweet" : { "properties" : { "flag" : { "type" : "boolean", "index" : "no", "fields" : { "untouched" : {"type" : "boolean"} } } } } }
こんな形で変換される。
"index":"no"
は無駄にデータ量食いたくないので。
でもソートクエリ書くときの処理を型によって変えたくなかったり、完全一致の検索とかなんやかんやでこの形を試した。
ただこのmappingを1.2.1のバージョンで登録すると
{ "tweet" : { "properties" : { "flag" : { "type" : "boolean", "index" : "no" } } } }
こうなって、untouchedフィールドの師弟が消えてしまった。
アップデートではやってくれるのになーと思いつつ、下記の方法で対処。
{ "tweet" : { "properties" : { "flag" : { "type" : "string", "index" : "no", "fields" : { "untouched" : {"type" : "boolean"} } } } } }
どうせデフォルトフィールドは"index":"no"
なので型は気にせず文字列にしてしまって、untouchedにはboolean型。
ansibleの続きお勉強は土日に。
今日の勉強会のこれの
やってられっか
この気持ちは大事だ。。。
やりたい人ががんがん推し進める、その為に頑張る。