2017-09-08 17 views
1

に私は次のようにマッピングされたテキスト/キーワードフィールドでES、中に私の文書にentity_nameフィールドを持っている:Elasticsearch 5 - テキスト/キーワードフィールドでの大文字小文字を区別しない完全一致

{ 
    "my_index": { 
    "mappings": { 
     "my_type": { 
     "properties": { 
      "entity_name": { 
      "type": "text", 
      "fields": { 
       "keyword": { 
       "type": "keyword", 
       "ignore_above": 256 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 

私は何「ABC Company」、「会社abc」のような「entity_name」フィールドに「ABC」を含むドキュメントを取得するクエリを作成することですが、「ABC」のような大文字と小文字を区別しないものを除外する必要があります(「ABC」、 'abc'、 'Abc')。

私のようなクエリを試してみた:

{ 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "match_phrase": { 
      "entity_name": "ABC" 
      } 
     } 
     ], 
     "must_not": [ 
     { 
      "term": { 
      "entity_name.keyword": "ABC" 
      } 
     } 
     ] 
    } 
    } 
} 

をしかし、それはケース非感受性の問題を処理しません。

ご協力いただければ幸いです。事前に感謝:)

答えて

1

てみは

{ 
    "my_index": { 
    "settings": { 
     "analysis": { 
     "analyzer": { 
      "case_insensitive": { 
       "tokenizer": "keyword", 
       "filter": [ 
        "lowercase" 
       ] 
      } 
     } 
     } 
    }, 
    "mappings": { 
     "my_type": { 
     "properties": { 
      "entity_name": { 
      "type": "text", 
      "analyzer": "case_insensitive", 
      "fields": { 
       "keyword": { 
       "type": "keyword", 
       "ignore_above": 256 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 

https://www.elastic.co/guide/en/elasticsearch/reference/5.4/analysis-tokenizers.html

検索をフィルタリングを助けるために、それにトークナイザを追加します
関連する問題