Delete by query - Error invalid_type_name_exception


(abdujaprov) #1

Hi,
I am trying to delete some elements with delete_by_query.
I should remove 5 elements:
curl -XGET 'localhost:9200/product_metadata/_count?pretty' -d '{"query": {"match":{"type.identifier": "plastic"}}}'

If I executed the delete by query I receive and error:

-bash-4.2$ curl -XPOST 'localhost:9200/product_metadata/delete_by_query?pretty' -d '{"query": {"match":{"type.identifier": "plastic"}}}'
{
"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
}

This is one of the element I found with the search:

{
"_index" : "product_metadata",
"_type" : "product_metadata",
"_id" : "a234255e-bedb-40f6-95b8-1dab5504e8f7",
"_score" : 5.5263844,
"_source" : {
"@class" : "it.altecspace.asdp.productmanager.curator.CuratedProduct",
"name" : "STA_LB_PLA_BROWSE_20180208_V12.cdf",
"id" : {
"uuid" : "a234255e-bedb-40f6-95b8-1dab5504e8f7"
},
"type" : {
"@class" : "it.altecspace.asdp.core.api.product.ProductType",
"identifier" : "lasco/plastic+ahead",
"description" : "Plastic product"
},
"metadata" : {
"asdp" : {
"product" : {
"ingested_on" : "20180213053542923"
}
}
},
"location" : {
"@class" : "it.altecspace.asdp.productmanager.archivist.ProductLocation",
"archive" : "default",
"location" : "file:///asdp-data/data/fsarchive/archive/a234255e-bedb-40f6-95b8-1dab5504e8f7/"
}
}
}

Where do I make a mistake?

I am able to delete each element specifying index and type:

curl -XDELETE http://localhost:9200/product_metadata/product_metadata/810ee996-6d45-4cb5-964e-f205b4a94431/?pretty

But I need to use delete by query.

If I specify index and type I receive this:

-bash-4.2$ curl -XPOST 'localhost:9200/product_metadata/product_metadata/_delete_by_query?pretty' -d '{"query": {"match":{"type.identifier": "plastic"}}}'
{
"_index" : "product_metadata",
"_type" : "product_metadata",
"_id" : "_delete_by_query",
"_version" : 8,
"result" : "updated",
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"created" : false
}

Bye


(EL) #2

I think your ES is in an older version and not supporting plugin delete_by_query.
In your return from" curl -XPOST 'localhost:9200/product_metadata/product_metadata/_delete_by_query?pretty' -d '{"query": {"match":{"type.identifier": "plastic"}}}' ", it shows you have build up a new doc with ID "_delete_by_query".
In another word, you were actually executing a "creating" instead of "delete by query".
Solution: 1.check your version, old version do not support "delete by query"
2. check plugin list to see if "delete by query" is installed
Tips: "delete_by_query" is not a function in ES anymore. It is a plugin.


(system) #3

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