小编use*_*259的帖子

使用java api配置elasticsearch映射

在索引之前,我有一些我不想分析的弹性搜索字段.我已经读过,正确的方法是改变索引映射.现在我的映射看起来像这样:

{
  "test" : {
   "general" : {
      "properties" : {
        "message" : {
          "type" : "string"
        },
        "source" : {
          "type" : "string"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我希望它看起来像这样:

{
  "test" : {
   "general" : {
      "properties" : {
        "message" : {
          "type" : "string",
          "index" : "not_analyzed"
        },
        "source" : {
          "type" : "string"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我一直试图通过改变设置

client.admin().indices().prepareCreate("test")
        .setSettings(getGrantSettings());
Run Code Online (Sandbox Code Playgroud)

getGrantSettings()的位置如下:

static Settings getGrantSettings(){
    JSONObject settingSource = new JSONObject();
    try{
        settingSource.put("mapping", new JSONObject()
        .put("message", new JSONObject() …
Run Code Online (Sandbox Code Playgroud)

java mapping analyzer elasticsearch

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

analyzer ×1

elasticsearch ×1

java ×1

mapping ×1