Java elasticsearch spring-data set different index field name
<p>I'm using elasticsearch java-api in combination with spring-data and have a problem with indexing a document. 
I want a different name for an indexed field. That means not the same as in the java code:</p>

<p>Domainobject:</p>

<pre><code>@Document(indexName = "testindex", type = "message")
public class MessageObject {

@Id
private String  unid;

@FieldNameInElasticIndex(value = "javaMessage")  // I want anything like that
private String message;

private String secondMessage;

private String thirdMessage;

...

getters &amp; setters

...

}
</code></pre>

<p>Interface:</p>

<pre><code>public interface MessageObjectRepository extends ElasticsearchRepository&lt;MessageObject, Long&gt; {


}
</code></pre>

<p>Service:</p>

<pre><code>@Component
public class MessageService {

    @Autowired
    private MessageObjectRepository repository;


    public void addRegistrationObject(MessageObject msg) {

        repository.save(msg);
    }
}
</code></pre>

<p>So....</p>

<p>is it possible to change the name so the index would look like:</p>

<pre><code>"hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "testindex",
        "_type": "message",
        "_id": "00113B325ED357B7C1257E2D001D5B4B",
        "_score": 1,
        "_source": {
          "unid": "00113B325ED357B7C1257E2D001D5B4B",
          "javaMessage": "Hello",  // &lt;--- this is what I want (javaMessage)
          "secondMessage": null,
          "thirdMessage": "Third",
</code></pre>

<p>instead of</p>

<pre><code>"hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "testindex",
        "_type": "message",
        "_id": "00113B325ED357B7C1257E2D001D5B4B",
        "_score": 1,
        "_source": {
          "unid": "00113B325ED357B7C1257E2D001D5B4B",
          "message": "Hello",  // &lt;--- this is NOT what I want (java name: message)
          "secondMessage": null,
          "thirdMessage": "Third",
</code></pre>

<p>?</p>