大文字と小文字を区別する unit というフィールド (kWh など) でアイテムをクエリしようとしましたが、用語クエリは kwh (小文字の W) をクエリした場合にのみ一致します。私がドキュメントで見たのは、用語は大文字と小文字を区別するための正しい用語である必要があるため、何が間違っているのかわかりません。
## Create an item
curl -X POST "localhost:9200/my_index/my_type/my_id" -H 'Content-Type: application/json' -d'{"point_name" : "my_point_name", "unit" : "kWh"}'
=> {"_index":"my_index","_type":"my_type","_id":"my_id","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}
## Try to query it by unit with exact match (kWh)
curl -X GET "localhost:9200/my_index/my_type/_search" -H 'Content-Type: application/json' -d'{"query" : { "bool" : {"must" : [{ "term" : {"unit" : "kWh"}}]}}}'
=> {"took":36,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
## Query with lower case unit kwh
curl -X GET "localhost:9200/my_index/my_type/_search" -H 'Content-Type: application/json' -d'{"query" : { "bool" : {"must" : [{ "term" : {"unit" : "kwh"}}]}}}'
=> {"took":12,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":1,"max_score":0.2876821,"hits":[{"_index":"my_index","_type":"my_type","_id":"my_id","_score":0.2876821,"_source":{"point_name" : "my_point_name", "unit" : "kWh"}}]}}
他のフィールドでもこれらのクエリを作成し、完全一致の動作を保証したいので、ここでは一致を使用したくありません。クエリがどのように正しいのか、このクエリという用語が機能しない理由を誰か教えてもらえますか?
この dockerimage をサーバーとして使用しています。
docker.elastic.co/elasticsearch/elasticsearch:6.2.4