I have a code to create a mapping on an existing index with the RHLC 6.7.0.
I'd like to give a name to this mapping. I understand that types are going to diasppear but does it mean that a mapping will always be called _doc ?
There is a method .type() for the PutMappingRequest in the javadoc (https://www.javadoc.io/doc/org.elasticsearch/elasticsearch/6.7.0) but it seems that it's not shipped with the package...
Maven dependancy :
Hmmm. That sounds right. Apparently type(String) has not been implemented in 6.7 and marked as deprecated at the same time. Which would be a bit weird to add a deprecated method.
I guess that when you are using this API you should just ignore the type whatever API you are calling then.
I think it's not only for 6.7 but also for 7.x.
It's not a big problem, I can stick with the default _doc name for the mapping, but a custom name would would me more clear.
EDIT.
And I forgot to add that when using
IndexRequest indexRequest = new IndexRequest(indexName, "_doc")
.id("1").source(doc);
I have to set the type _doc or I get an error:
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
at java.lang.Thread.run (Thread.java:748)
Caused by: org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: type is missing;
at org.elasticsearch.action.ValidateActions.addValidationError (ValidateActions.java:26)
at org.elasticsearch.action.index.IndexRequest.validate (IndexRequest.java:155)
at org.elasticsearch.client.RestHighLevelClient.performRequest (RestHighLevelClient.java:1730)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity (RestHighLevelClient.java:1696)
at org.elasticsearch.client.RestHighLevelClient.index (RestHighLevelClient.java:928)
at com.test.ElasticClient.insertDocument (ElasticClient.java:191)
at com.test.App.main (App.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
at java.lang.Thread.run (Thread.java:748)
Ok, but you have to specify the mapping type, which is _doc. Maybe I misunderstood your last comment, you suggested to ignore the type, but it must be specified. I'll try all this with 7.x, but it's still not clear to me if it's possible to give a custom name to the mapping when using the RHLC, for whatever version superior to 6.7.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.