Bulk: allow null values in action/metadata line parameters
Closes #11458
This commit is contained in:
parent
a3f51544d5
commit
a805cef045
|
@ -332,7 +332,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
|||
} else {
|
||||
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter [" + currentFieldName + "]");
|
||||
}
|
||||
} else {
|
||||
} else if (token != XContentParser.Token.VALUE_NULL) {
|
||||
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,4 +177,12 @@ public class BulkRequestTests extends ElasticsearchTestCase {
|
|||
e.getMessage().contains("Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [START_ARRAY]"), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleBulk10() throws Exception {
|
||||
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk10.json");
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
bulkRequest.add(bulkAction.getBytes(Charsets.UTF_8), 0, bulkAction.length(), null, null);
|
||||
assertThat(bulkRequest.numberOfActions(), equalTo(9));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{ "index" : {"_index":null, "_type":"type1", "_id":"0"} }
|
||||
{ "field1" : "value1" }
|
||||
{ "index" : {"_index":"test", "_type":null, "_id":"0"} }
|
||||
{ "field1" : "value1" }
|
||||
{ "index" : {"_index":"test", "_type":"type1", "_id":null} }
|
||||
{ "field1" : "value1" }
|
||||
{ "delete" : {"_index":null, "_type":"type1", "_id":"0"} }
|
||||
{ "delete" : {"_index":"test", "_type":null, "_id":"0"} }
|
||||
{ "delete" : {"_index":"test", "_type":"type1", "_id":null} }
|
||||
{ "create" : {"_index":null, "_type":"type1", "_id":"0"} }
|
||||
{ "field1" : "value1" }
|
||||
{ "create" : {"_index":"test", "_type":null, "_id":"0"} }
|
||||
{ "field1" : "value1" }
|
||||
{ "create" : {"_index":"test", "_type":"type1", "_id":null} }
|
||||
{ "field1" : "value1" }
|
Loading…
Reference in New Issue