Elasticsearch使整个索引或类型not_analyzed

时间:2015-08-06 21:42:26

标签: lucene elasticsearch

当我创建弹性搜索索引时,我不知道将使用新文档插入哪些字段。因此,我无法在创建索引时指定哪些字段为"index": "not_analyzed"。幸运的是,我希望所有字段都是not_analyzed,那么有没有办法获得整个索引或类型,这意味着所有创建的字段not_analyzed

1 个答案:

答案 0 :(得分:1)

As per documentation while creating index define analyzer default or default_index to be of type keyword.

Example

{
   "settings": {
      "analysis": {
         "analyzer": {
            "default": {
               "type": "keyword"
            }
         }
      }
   }
}

You can also scope the analyzer per type at the moment but looks like it will be deprecated in the future issue 8874.

However currently you can set default analyzer for a type in the mapping as follows :

put test/test_type/_mapping
{
   "test_type" : { 
         "analyzer": "keyword"
   }
}