I got clear explanation through email.
So, in some cases I will success on it, in some cases not!
It means if doc is found without routing value it can be deleted, otherwise not.
Here is the experiment I got and id=3 or id=4 certainly CANNOT BE DELETED because of routing value.
Thanks for ES dev group!
Here is the Experiment
Define your index
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"my_join_field": {
"type": "join",
"relations": {
"question": "answer"
}
}
}
}
}
}
Index doc 1
PUT my_index/_doc/1?refresh
{
"text": "This is a question",
"my_join_field": "question"
}
Index doc 2
PUT my_index/_doc/2?refresh
{
"text": "This is another question",
"my_join_field": "question"
}
Index doc 3 (answer to q1)
PUT my_index/_doc/3?routing=1&refresh
{
"text": "This is an answer",
"my_join_field": {
"name": "answer",
"parent": "1"
}
}
Index doc 4 (answer to q2)
PUT my_index/_doc/4?routing=2&refresh
{
"text": "This is another answer",
"my_join_field": {
"name": "answer",
"parent": "2"
}
}
Search for all parent child (returns total of 4 documents)
GET my_index/_search
{
"query": {
"match_all": {}
},
"sort": ["_id"]
}
GET _cat/indices/my_index?v
GET _cat/shards/my_index?v
Deleting documents 1 to 4, 3 or 4 doc deletion will fail
DELETE my_index/_doc/1
DELETE my_index/_doc/2
DELETE my_index/_doc/3
DELETE my_index/_doc/4
You should still see 1 or 2 orphan documents exist in the index
GET _cat/shards/my_index?v
To completely remove the documents - you'll need to provide the routing
DELETE my_index/_doc/3?routing=1
DELETE my_index/_doc/4?routing=2
Now it should be completely clear
GET _cat/shards/my_index?v
Confirm your search again
GET my_index/_search
{
"query": {
"match_all": {}
},
"sort": ["_id"]
}
Delete when done / convinced
DELETE my_index