Determine Shard Id based on routing key

Hi

Say I create an index with 20 shards.

During indexing, if I specify a routing_key as 0, will it be indexed in
shardId 0? Will routing_key 3 correspond to shard Id 3? Similarly for all
other keys if I have 20 unique routing values since 0 % 20 will be 0 and 3
% 20 will be 3, etc.

There is no hash but a specific set of routing keys [0..19] = number of
shards [0..19] that I have.

Is this deterministic and documented by ES regarding this routing key to
shard Id behavior? Or is it internal to ES and changeable anytime?

Please let me know soon!! Thanks in advance...

Thanks,
Sandeep

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/32b16cf4-517e-4b33-9eb8-129cf5bd8cf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Sandeep,

Routing is deterministic, otherwise we couldn't know where data is located
when using the get API (this API goes to a single shard, not all of them).
However, you should not rely on the distribution of the hash values as this
is an implementation detail that we could indeed change at some point.

I don't know what your use-case is, but if you really need to manage the
sharding yourself, the easiest way to do it would be to creates 20 indices
with 1 shard instead of 1 index with 20 shards. I would discourage to do it
though.

On Thu, Aug 28, 2014 at 8:31 AM, 'Sandeep Ramesh Khanzode' via
elasticsearch elasticsearch@googlegroups.com wrote:

Hi

Say I create an index with 20 shards.

During indexing, if I specify a routing_key as 0, will it be indexed in
shardId 0? Will routing_key 3 correspond to shard Id 3? Similarly for all
other keys if I have 20 unique routing values since 0 % 20 will be 0 and 3
% 20 will be 3, etc.

There is no hash but a specific set of routing keys [0..19] = number of
shards [0..19] that I have.

Is this deterministic and documented by ES regarding this routing key to
shard Id behavior? Or is it internal to ES and changeable anytime?

Please let me know soon!! Thanks in advance...

Thanks,
Sandeep

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/32b16cf4-517e-4b33-9eb8-129cf5bd8cf0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/32b16cf4-517e-4b33-9eb8-129cf5bd8cf0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4rczExhUwa1NSLLeekx%2BHzMFTcoYNrT5hbGeqPJSp-bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hi Adrian,

Thanks for the reply. That was important for me to understand.

However, I am a little concerned with your comment on the equivalence of 1
index with 20 shards and 20 indices with one shard each. You mentioned that
you would discourage the latter.

Can you please explain why? Is it for management reasons or performance
overhead reasons? I can deal with the former but not the latter unless if
you have some pointers. Thanks,

Thanks,
Sandeep

On Thursday, 28 August 2014 13:28:32 UTC+5:30, Adrien Grand wrote:

Hi Sandeep,

Routing is deterministic, otherwise we couldn't know where data is
located when using the get API (this API goes to a single shard, not all of
them). However, you should not rely on the distribution of the hash values
as this is an implementation detail that we could indeed change at some
point.

I don't know what your use-case is, but if you really need to manage the
sharding yourself, the easiest way to do it would be to creates 20 indices
with 1 shard instead of 1 index with 20 shards. I would discourage to do it
though.

On Thu, Aug 28, 2014 at 8:31 AM, 'Sandeep Ramesh Khanzode' via
elasticsearch <elasti...@googlegroups.com <javascript:>> wrote:

Hi

Say I create an index with 20 shards.

During indexing, if I specify a routing_key as 0, will it be indexed in
shardId 0? Will routing_key 3 correspond to shard Id 3? Similarly for all
other keys if I have 20 unique routing values since 0 % 20 will be 0 and 3
% 20 will be 3, etc.

There is no hash but a specific set of routing keys [0..19] = number of
shards [0..19] that I have.

Is this deterministic and documented by ES regarding this routing key to
shard Id behavior? Or is it internal to ES and changeable anytime?

Please let me know soon!! Thanks in advance...

Thanks,
Sandeep

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/32b16cf4-517e-4b33-9eb8-129cf5bd8cf0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/32b16cf4-517e-4b33-9eb8-129cf5bd8cf0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fc1cc1c3-9987-4f51-98f9-0878145e6c66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

On Mon, Sep 1, 2014 at 1:18 PM, 'Sandeep Ramesh Khanzode' via elasticsearch
elasticsearch@googlegroups.com wrote:

However, I am a little concerned with your comment on the equivalence of 1
index with 20 shards and 20 indices with one shard each. You mentioned that
you would discourage the latter.

Can you please explain why? Is it for management reasons or performance
overhead reasons? I can deal with the former but not the latter unless if
you have some pointers. Thanks,

Sorry for the confusion, what I would like to discourage is not having 20
indices with one shard but trying to manage sharding manually instead of
relying on elasticsearch's routing mechanism that abstracts the number of
shards.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5R4-BOtaMkFTDB1PfpVqVrh4BQb%3D4TsAfseOiCFP79Fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hi Adrien,

Is it possible to intercept the Search Response, on the server itself,
from the ES Server to the node hosting the TransportClient? I can use a
plugin to do that, but I have no idea which classes to extend and which
modules to register. Can you please provide some details? Thanks,

Thanks,
Sandeep

On Mon, Sep 1, 2014 at 4:52 PM, Adrien Grand <adrien.grand@elasticsearch.com

wrote:

On Mon, Sep 1, 2014 at 1:18 PM, 'Sandeep Ramesh Khanzode' via
elasticsearch elasticsearch@googlegroups.com wrote:

However, I am a little concerned with your comment on the equivalence of
1 index with 20 shards and 20 indices with one shard each. You mentioned
that you would discourage the latter.

Can you please explain why? Is it for management reasons or performance
overhead reasons? I can deal with the former but not the latter unless if
you have some pointers. Thanks,

Sorry for the confusion, what I would like to discourage is not having 20
indices with one shard but trying to manage sharding manually instead of
relying on elasticsearch's routing mechanism that abstracts the number of
shards.

--
Adrien Grand

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Hh5uhhb70Mo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5R4-BOtaMkFTDB1PfpVqVrh4BQb%3D4TsAfseOiCFP79Fg%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5R4-BOtaMkFTDB1PfpVqVrh4BQb%3D4TsAfseOiCFP79Fg%40mail.gmail.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKnM90ZCbT%2Bf2hS0dR7YHP6mkdVU4%3DutNNTPBkVQnT6HYgDf_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.