Java IndexRequest Default value of type

If I do not specify "_doc" as my type in an IndexRequest like so,

`new IndexRequest(esIndex, "_doc",record.getIndex())
                    .source(esRecord.getData().toString(), XContentType.JSON)`

I get the exception,
exception [type=illegal_argument_exception, reason=Rejecting mapping update to [cartoon-raw-ekenebt-2019-01-21] as the final mapping would have more than 1 type: [_doc, SEEC0746A8F2B5_26JUL071p0019145AASEEC079j000999]]]]

I can't figure out why adding "_doc" fixes this exception?

Running version 6.2.4

There are a number of constructors for IndexRequest, and the two relevant ones here are:

    public IndexRequest(String index, String type);
    public IndexRequest(String index, String type, String id);

When you pass three arguments you are giving the index, the type, and the document ID, but when you pass two you are giving the index and the type. The error message indicates that you are passing SEEC0746A8F2B5_26JUL071p0019145AASEEC079j000999 for the type, but this looks like a document ID, and that is probably not what you want.

I am doing this in preparation for the removal of mapping types in elasticsearch. This is where I used to have my project specific type value. With the removal of types, will I always put "_doc" in for the type field? I know there is the notion of custom types but in general what should I put in for type once I have removed type from my index mapping?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.