-
Notifications
You must be signed in to change notification settings - Fork 25.2k
BulkProcessor no error when dynamic is strict #55043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Pinging @elastic/es-core-features (:Core/Features/Java High Level REST Client) |
Pinging @elastic/es-search (:Search/Mapping) |
Thanks @moifort for raising this. To help us with debugging, would you be able to provide a single example document where you expect to see an error, but you see a successful response instead? |
mapping.json{
"dynamic": "strict",
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "text",
}
} Bulk success but no data in ElasticsearchDocuments below do not respect mapping [
{
"id" : 1,
"name" : "name1-s5",
"summaryHtml" : "the-summary1-s5",
"categoryId" : 10004
},
{
"id" : 2,
"name" : "name2-s5",
"summaryHtml" : "the-summary2-s5",
"categoryId" : 10004
},
{
"id" : 3,
"name" : "name3-s5",
"summaryHtml" : "the-summary3-s5",
"categoryId" : 10004
}
] Bulk success and data are stored in Elasticsearch[
{
"id" : 1,
"name" : "name1-s5"
},
{
"id" : 2,
"name" : "name2-s5"
},
{
"id" : 3,
"name" : "name3-s5"
}
] |
@moifort thanks for the reproduction. I think the behaviour is expected. Note that in your example you are expecting an error for the whole bulk request if some or all of the operations fail, but that's not how the bulk API works. Please note that if you send a "_bulk" request via REST api with one document that should succeed (has no unknown fields that would cause the "strict" setting to error) and another that should fail like this:
the response contains the top-level
I believe that with the Java client you can check those properties with I will check our documentation if we have examples for this in the REST Api docs and the High Level Client docs because I can imagine this being a more frequent ask, maybe we should add a few lines and/or an example to the docs. |
Re: the docs situation: at least the High Level Rest Client documentation has a section and examples about operations with failures in the section about the BulkResponse. |
Pinging @elastic/es-docs (>docs) |
Thanks @cbuescher. I agree. We do mention failures in the REST Bulk API docs:
However, it doesn't look like we document the |
Thanks @jrodewig, that should cover the documentation side. |
Thank you all, for your reactivity and answers! Indeed, I should test BulkListener.java @Slf4j
public class BulkListener implements BulkProcessor.Listener {
@Override
public void beforeBulk(long executionId, BulkRequest request) {
var numberOfActions = request.numberOfActions();
LOG.trace("Executing bulk [{}] with {} requests", executionId, numberOfActions);
}
@Override
public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {
LOG.trace("Bulk [{}] completed in {} milliseconds", executionId, response.getTook().getMillis());
if (response.hasFailures()) { // Catch the strict error
LOG.error(response.buildFailureMessage());
}
}
@Override
public void afterBulk(long executionId, BulkRequest request, Throwable failure) {
LOG.error("Failed to execute bulk", failure);
}
} log
@jrodewig where I can make a PR to update the sample and the documentation? |
Hi @moifort A PR would be most welcome! The source file for the REST Bulk API docs is here: However, please note that the REST API docs are separate from the Java HLRC docs. The Java HLRC docs already include documentation for If you'd like to raise a PR for the Java HLRC docs, the source file is here: I'm glad to hear you were able to resolve the issue! |
Elasticsearch version (
bin/elasticsearch --version
): docker imageelasticsearch:7.4.2
Plugins installed: [] default
JVM version (
java -version
): docker imageelasticsearch:7.4.2
OS version (
uname -a
if on a Unix-like system): docker imageelasticsearch:7.4.2
elasticsearch-rest-high-level-client : 7.6.2 on JDK 11
Description of the problem including expected versus actual behavior:
When using
dynamic: strict
mapping setting:Steps to reproduce:
mapping.json
storeData.java
bulkListener.java
Provide logs (if relevant):
When I call
StoreData.seed()
with field that is no defined onmapping.json
log
kibana
The text was updated successfully, but these errors were encountered: