(java) I don’t know why this error occurs [Validation Failed: 1: no requests added]


simple code (java)

public void run(){

    	int count = 0;
    	BulkRequest buklRequest = new BulkRequest();
    		IndexRequest indexRequest = new IndexRequest(index, type, id);
    		if(count == 1000){
    			count = 0;
    			insertBulkLog(buklRequest);  <---- true
    			buklRequest = new BulkRequest();
    	insertBulkLog(buklRequest);   <-----false, error

    public boolean insertBulkLog(BulkRequest bulkRequest){

    	RestHighLevelClient client = new RestHighLevelClient();
    	BulkResponse bulkResponse = client.bulk(buklRequest, RequstOption.Default);  <----error

org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: no requests added

An error message is generated, but the log is processed normally.

(David Pilato) #2

I don't see the full code but may be the last call does not add any new document?

BTW you should look at the BulkProcessor class.

(Bin Dai) #3

please look at my topic in which this problem is fixed but i dont know why shoud do so. you need add one more line before or after the bulkProcessor.add which is "bulkRequest.add". My code is like this

bulkRequest.add(new IndexRequest("articles", "article", String.valueOf(j)).source(lineTxt, XContentType.JSON));
bulkProcessor.add(new IndexRequest("articles", "article", String.valueOf(j)).source(lineTxt, XContentType.JSON));

(system) closed #4

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