Skip to content

Commit 4348959

Browse files
committed
Delete api: remove broadcast delete if routing is missing when required
This commit changes the behaviour of the delete api when processing a delete request that refers to a type that has routing set to required in the mapping, and the routing is missing in the request. Up until now the delete api sent a broadcast delete request to all of the shards that belong to the index, making sure that the document could be found although the routing value wasn't specified. This was probably not the best choice: if the routing is set to required, an error should be thrown instead. A `RoutingMissingException` gets now thrown instead, like it happens in the same situation with every other api (index, update, get etc.). Last but not least, this change allows to get rid of a couple of `TransportAction`s, `Request`s and `Response`s and simplify the codebase. Closes #9123 Closes #10136
1 parent 780fe57 commit 4348959

16 files changed

+30
-703
lines changed

docs/reference/migration/migrate_2_0.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ shards aren't being kept track of. From version 2.0 the stats in the `_shards` h
161161
of an index. The http status code is left unchanged and is only based on failures that occurred while executing on
162162
primary shards.
163163

164+
=== Delete api with missing routing when required
165+
166+
Delete api requires a routing value when deleting a document belonging to a type that has routing set to required in its
167+
mapping, whereas previous elasticsearch versions would trigger a broadcast delete on all shards belonging to the index.
168+
A `RoutingMissingException` is now thrown instead.
169+
164170
=== Mappings
165171

166172
* The setting `index.mapping.allow_type_wrapper` has been removed. Documents should always be sent without the type as the root element.

src/main/java/org/elasticsearch/action/ActionModule.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@
129129
import org.elasticsearch.action.count.TransportCountAction;
130130
import org.elasticsearch.action.delete.DeleteAction;
131131
import org.elasticsearch.action.delete.TransportDeleteAction;
132-
import org.elasticsearch.action.delete.TransportIndexDeleteAction;
133-
import org.elasticsearch.action.delete.TransportShardDeleteAction;
134132
import org.elasticsearch.action.deletebyquery.DeleteByQueryAction;
135133
import org.elasticsearch.action.deletebyquery.TransportDeleteByQueryAction;
136134
import org.elasticsearch.action.deletebyquery.TransportIndexDeleteByQueryAction;
@@ -282,8 +280,7 @@ protected void configure() {
282280
TransportDfsOnlyAction.class);
283281
registerAction(MultiTermVectorsAction.INSTANCE, TransportMultiTermVectorsAction.class,
284282
TransportShardMultiTermsVectorAction.class);
285-
registerAction(DeleteAction.INSTANCE, TransportDeleteAction.class,
286-
TransportIndexDeleteAction.class, TransportShardDeleteAction.class);
283+
registerAction(DeleteAction.INSTANCE, TransportDeleteAction.class);
287284
registerAction(CountAction.INSTANCE, TransportCountAction.class);
288285
registerAction(ExistsAction.INSTANCE, TransportExistsAction.class);
289286
registerAction(SuggestAction.INSTANCE, TransportSuggestAction.class);

src/main/java/org/elasticsearch/action/delete/IndexDeleteRequest.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/main/java/org/elasticsearch/action/delete/IndexDeleteResponse.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/main/java/org/elasticsearch/action/delete/ShardDeleteRequest.java

Lines changed: 0 additions & 123 deletions
This file was deleted.

src/main/java/org/elasticsearch/action/delete/ShardDeleteResponse.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)