madhurir
(Madhuri)
October 31, 2021, 2:08am
1
I am using version 7.15 and trying to create bulk index request in my dev environment. Though the single indexing works, bulk indexing doesn't. I don't see any exception but I see the following in my IntelliJ logs
[ pool-11-thread-1] RestClient WARN request [POST http://localhost:9200/_bulk?timeout=1m] returned 2 warnings:
and the page following the link in the above logs shows
{"error":"Incorrect HTTP method for uri [/_bulk?timeout=1m] and method [GET], allowed: [POST, PUT]","status":405}
Here is my code
RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", "9200", "http")));
BulkRequest request = new BulkRequest();
request.add(new IndexRequest("posts", "doc", "1").source(XContentType.JSON,"field", "foo"));
request.add(new IndexRequest("posts", "doc", "2").source(XContentType.JSON,"field", "bar"));
request.add(new IndexRequest("posts", "doc", "3").source(XContentType.JSON,"field", "baz"));
BulkResponse bulkResponse = restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
stephenb
(Stephen Brown)
October 31, 2021, 2:19am
2
Hi @madhurir Welcome to the community.
I am not an expert on the Java HLRC but looks like your syntax perhaps is not correct? See here
BulkRequest request = new BulkRequest();
request.add(new IndexRequest("posts").id("1")
.source(XContentType.JSON,"field", "foo"));
request.add(new IndexRequest("posts").id("2")
.source(XContentType.JSON,"field", "bar"));
request.add(new IndexRequest("posts").id("3")
.source(XContentType.JSON,"field", "baz"));
madhurir
(Madhuri)
October 31, 2021, 6:29am
3
No, luck. I think I need to change the http method to post/put as in the above example, it think of the requests as http get.
dadoonet
(David Pilato)
October 31, 2021, 7:29am
4
Welcome!
What exact version of the client are you using?
I'm using bulk with 7.15.1 with no problem on my side. Have a look at
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package fr.pilato.elasticsearch.injector.injector;
This file has been truncated. show original
system
(system)
Closed
November 28, 2021, 7:30am
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.