【问题标题】:How to get default analyzer of index如何获取索引的默认分析器
【发布时间】:2015-02-10 13:47:08
【问题描述】:

我会用这个定义为索引设置默认分析器:

"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"
        }
      }
    }
  }
}

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

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

    在您的 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"
                }
             }
          }
       }
    }
    

    编辑:

    问题在于“简单”周围的单引号,所有键/值都应该用双引号 - Maxim K。

    JSON syntax 需要使用双引号。

    【讨论】:

    • 同样的结果。你用的是什么版本?我使用 1.4.2 并且需要在 POST 请求中的“索引”之前删除 { 以获得响应 {acknowledged: true}
    • 版本 1.4.1。我使用了我编写的确切代码。它可以在我的 ES 实例上使用和不使用“删除”。 “相同的结果”是指您仍然没有得到正确的设置吗?
    • 问题在于“简单”周围的单引号,所有键/值都应该用双引号
    • 观察良好@MaximK。我没有意识到这是问题所在。 :)
    猜你喜欢
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-27
    • 2017-06-27
    • 2021-06-06
    相关资源
    最近更新 更多