title: Configure elasticsearch mapping with java api
body: <p>I have a few elasticsearch fields that I don't want to analyze before indexing. I have read that the right way to do this is by altering the index mapping. Right now my mapping looks like this:</p>
  
  <pre><code>{
    "test" : {
     "general" : {
        "properties" : {
          "message" : {
            "type" : "string"
          },
          "source" : {
            "type" : "string"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>And I would like it to look like this:</p>
  
  <pre><code>{
    "test" : {
     "general" : {
        "properties" : {
          "message" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "source" : {
            "type" : "string"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I have been trying to change the settings via</p>
  
  <pre><code>client.admin().indices().prepareCreate("test")
          .setSettings(getGrantSettings());
  </code></pre>
  
  <p>Where getGrantSettings() looks like:</p>
  
  <pre><code>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;
  }
  </code></pre>