From 3ae40487b6166a2610ca07296378b869cbc53670 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 1 Sep 2011 18:33:44 +0300 Subject: [PATCH] Using 57744018578214912 as an id can cause failure to route to the correct shard, closes #1294. --- .../routing/operation/plain/PlainOperationRouting.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java index 75f1f7c0231..a8e22df0226 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java @@ -216,12 +216,12 @@ public class PlainOperationRouting extends AbstractComponent implements Operatio private int shardId(ClusterState clusterState, String index, String type, @Nullable String id, @Nullable String routing) { if (routing == null) { if (!useType) { - return Math.abs(hash(id)) % indexMetaData(clusterState, index).numberOfShards(); + return Math.abs(hash(id) % indexMetaData(clusterState, index).numberOfShards()); } else { - return Math.abs(hash(type, id)) % indexMetaData(clusterState, index).numberOfShards(); + return Math.abs(hash(type, id) % indexMetaData(clusterState, index).numberOfShards()); } } - return Math.abs(hash(routing)) % indexMetaData(clusterState, index).numberOfShards(); + return Math.abs(hash(routing) % indexMetaData(clusterState, index).numberOfShards()); } protected int hash(String routing) {