Reputation: 1519
I am getting a warning:
"[types removal] Specifying types in bulk requests is deprecated."]
What do I do wrong? This is my code:
BulkRequest request = new BulkRequest();
for(Item item : items) {
IndexRequest indexRequest = new IndexRequest(INDEX_NAME, DOC_TYPE, item.getIdentifier());
indexRequest
.opType(DocWriteRequest.OpType.INDEX) // Index the source. If there an existing document with the id, it will be replaced.
.source(JsonUtility.toJson(item), XContentType.JSON);
request.add(indexRequest);
}
elastic.bulk(request, RequestOptions.DEFAULT);
Upvotes: 10
Views: 28103
Reputation: 21
I think you are working with a 7.X version and the problem is you create the IndexRequest are constructing the URL of the POST method to search in ElasticSearch, something close to:
Where identifier is the attribute used to discriminate in the search. In ElasticSearch 7 specifying types in search requests were deprecated and the URL should be something close to:
Although it is hard to know because you don't specify the versions, I think the elasticsearch library in your code is older than 7.X, if you updated it to 7 probably the DOC_TYPE param disappears in the constructor.
Upvotes: 0
Reputation: 2951
The mapping type
was removed in Elasticsearch 8 and is deprecated in Elasticsearch 7.
No Elasticsearch
version is mentioned in your question, but you can read more about the schedule for removal of mapping types, and react accordingly.
Upvotes: 8