Konfigurieren Sie die Elasticsearch-Zuordnung mit Java API

Ich habe einige Elasticsearch-Felder, die ich vor der Indizierung nicht analysieren möchte. Ich habe gelesen, dass der richtige Weg, dies zu tun, darin besteht, die Indexzuordnung zu ändern. Im Moment sieht mein Mapping so aus:

{
  "test" : {
   "general" : {
      "properties" : {
        "message" : {
          "type" : "string"
        },
        "source" : {
          "type" : "string"
        }
      }
    }
  }
}

Und ich möchte, dass es so aussieht:

{
  "test" : {
   "general" : {
      "properties" : {
        "message" : {
          "type" : "string",
          "index" : "not_analyzed"
        },
        "source" : {
          "type" : "string"
        }
      }
    }
  }
}

Ich habe versucht, die Einstellungen über zu ändern

client.admin().indices().prepareCreate("test")
        .setSettings(getGrantSettings());

So sieht getGrantSettings () aus:

static Settings getGrantSettings(){
    JSONObject settingSource = new JSONObject();
    try{
        settingSource.put("mapping", new JSONObject()
        .put("message", new JSONObject()
            .put("type", "string")
            .put("index", "not_analyzed")
        ));
    } catch (JSONException e){
        e.printStackTrace();
    }


    Settings set = ImmutableSettings.settingsBuilder()
            .loadFromSource(settingSource.toString()).build();
    return set;
}

Antworten auf die Frage(4)

Ihre Antwort auf die Frage