如何获取索引的默认分析器

How to get default analyzer of index

我将使用以下定义为索引设置默认分析器:

"index": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": 'simple'
        }
      }
    }
  }

但后来我通过查询获得了这个索引的设置 http://localhost:9200/test/_settings?pretty=true 我只得到这个,与分析器无关:

 {
  "test" : {
    "settings" : {
      "index" : {
        "creation_date" : "1423575850265",
        "uuid" : "Ac8QSGWbTtSCG7ib4VpV3Q",
        "number_of_replicas" : "1",
        "number_of_shards" : "5",
        "version" : {
          "created" : "1040299"
        }
      }
    }
  }
}

删除您的索引并重试。你的定义应该有效。它可能不起作用,因为已存在同名索引。

SENSE

中尝试以下代码
DELETE test

POST test
{
    "index" : {
        "analysis" : {
            "analyzer" : {
                "default" : {
                    "type" : "simple"
                }
            }
        }
    }
}

GET test/_settings

此代码返回:

{
   "test": {
      "settings": {
         "index": {
            "creation_date": "1423576958602",
            "uuid": "0iKpaL8uSKOSFT-oI1TJoQ",
            "analysis": {
               "analyzer": {
                  "default": {
                     "type": "simple"
                  }
               }
            },
            "number_of_replicas": "1",
            "number_of_shards": "5",
            "version": {
               "created": "1040199"
            }
         }
      }
   }
}

编辑:

Problem was with single quotes around 'simple', all should key/values should be in double quotes – Maxim K.

JSON syntax需要使用双引号。