I understand that _delete_by_query is now added to core, and no longer requires a plugin.
Using org.elasticsearch:elasticsearch:5.5.2, I am starting a org.elasticsearch.node.Node with:
public void before() throws Exception {
Settings settings = Settings.builder()
.put(NetworkModule.HTTP_TYPE_KEY, Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME)
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
.put(HttpTransportSettings.SETTING_HTTP_PORT.getKey(), port)
.put("path.home", path.getAbsolutePath())
.build();
node = new MyNode(InternalSettingsPreparer.prepareEnvironment(settings, null), Collections.singleton(Netty4Plugin.class)).start();
}
Then, I create a trivial index, add a document, query for the document, and then try to delete. ES keeps treating "_delete_by_query" like an id or a type mapping, not an API endpoint. What am I doing wrong?
When running the same version of ES as an application (ie. not from Java code), the endpoint works as expected.
$ curl -XPUT 'localhost:59200/foo?pretty' -H 'Content-Type: application/json' -d'
> {
> "mappings": {
> "bar": {
> "properties": {
> "baz": {
> "type": "keyword"
> }
> }
> }
> }
> }
> '
{
"acknowledged" : true,
"shards_acknowledged" : true
}
$ curl -XPUT 'localhost:59200/foo/bar/1?pretty' -H 'Content-Type: application/json' -d'{"baz":"lol"}'
{
"_index" : "foo",
"_type" : "bar",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
}
$ curl 'localhost:59200/foo/bar/_search?pretty'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "foo",
"_type" : "bar",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"baz" : "lol"
}
}
]
}
}
$ curl 'localhost:59200/foo/bar/_search?pretty' -d'
> {
> "query": {
> "match": {
> "baz": "lol"
> }
> }
> }
> '
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "foo",
"_type" : "bar",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"baz" : "lol"
}
}
]
}
}
$ curl -XPOST 'localhost:59200/foo/bar/_delete_by_query?pretty' -d'
> {
> "query": {
> "match": {
> "baz": "lol"
> }
> }
> }
> '
{
"_index" : "foo",
"_type" : "bar",
"_id" : "_delete_by_query",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
}
$ curl -XPOST 'localhost:59200/foo/_delete_by_query?pretty' -d'
> {
> "query": {
> "match": {
> "baz": "lol"
> }
> }
> }
> '
{
"error" : {
"root_cause" : [
{
"type" : "invalid_type_name_exception",
"reason" : "Document mapping type name can't start with '_', found: [_delete_by_query]"
}
],
"type" : "invalid_type_name_exception",
"reason" : "Document mapping type name can't start with '_', found: [_delete_by_query]"
},
"status" : 400
}