# Elasticseach is not matching ”\_id” between the clusters

**URL:** <https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865>\
**Category:** Elasticsearch\
**Created:** [January 28, 2015, 12:56am UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865 "2015-01-28T00:56:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Henrique\_de\_O](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Carlos\_Henrique\_de\_O](https://discuss.elastic.co/u/Carlos_Henrique_de_O)\
**Post date:** [January 28, 2015, 12:56am UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/1 "2015-01-28T00:56:51Z")

</div>

I have two Web Servers ws001 and ws002 working as load balance for  
Elasticseach and I am trying to catch/count the hits for a specific page  
which is something like this: [mysite.com/listing/item-123/](http://mysite.com/listing/item-123/).

Using the ES I am running curl –XGET http:  
[//mysite.com:9200/stats/listingviews/\_search?pretty](https://mysite.com:9200/stats/listingviews/_search?pretty) Then count the hits for  
a specific "\_id": "hits" : { "total" : 1526, "max\_score" : 1.0, "hits" : [  
{ "\_index" : "stats", "\_type" : "listingviews", "\_id" :  
"IYSs1OmqSvK6gRDQr61j3w", "\_score" : 1.0,  
"\_source":{"id":"1159","type":"listing","ua":"Mozilla/5.0 (Windows NT 6.1;  
WOW64; rv:34.0) Gecko/20100101  
Firefox/34.0","ip":"203.206.165.208","time":"2014-12-23 13:37:49"} }

When I test it on my dev environment (localhost) with only one node and  
there is no load balance applied it works perfect, I always find this "\_id"  
and the count works pretty good, but on my production with load balance  
activated I cannot find the results ("\_id") on both servers ws001 and ws002  
and it breaks my hits counting.

On my load balance servers I getting completely different results, I mean  
("\_id"), when I run: curl –XGET http:  
//webserver1:9200/stats/listingviews/\_search?pretty and curl –XGET http:  
//webserver2:9200/stats/listingviews/\_search?pretty. Also I already checked  
the shads for each server and they are different.

At the end, the \_ids found on both servers never match and definitely they  
are not the same ids. I’m supposing that the replica on the load balance is  
not working as replica and the ES is storing the data in both servers  
separately. Even if the \_ids are not on each server, the end result should  
be our ability to count how many records there are (ie. where \_source-\>id =  
1159) but it seems to only get a count from ws001.

Which approach should I take to solve this issue, and be able to count my  
hits on the production environment?

Thanks,

Carlos.

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 28, 2015, 1:06am UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/2 "2015-01-28T01:06:19Z")

</div>

So these two nodes are their own separate clusters?  
How are you indexing data into them? Are you using the auto ID generation  
within ES or specifying your own?

On 28 January 2015 at 11:56, Carlos Henrique de Oliveira \<  
[choliveira0604@gmail.com](mailto:choliveira0604@gmail.com)\> wrote:

> I have two Web Servers ws001 and ws002 working as load balance for  
> Elasticseach and I am trying to catch/count the hits for a specific page  
> which is something like this: [mysite.com/listing/item-123/](http://mysite.com/listing/item-123/).
> 
> Using the ES I am running curl –XGET http: //  
> [mysite.com:9200/stats/listingviews/\_search?pretty](http://mysite.com:9200/stats/listingviews/_search?pretty) Then count the hits for  
> a specific "\_id": "hits" : { "total" : 1526, "max\_score" : 1.0, "hits" : [  
> { "\_index" : "stats", "\_type" : "listingviews", "\_id" :  
> "IYSs1OmqSvK6gRDQr61j3w", "\_score" : 1.0,  
> "\_source":{"id":"1159","type":"listing","ua":"Mozilla/5.0 (Windows NT 6.1;  
> WOW64; rv:34.0) Gecko/20100101  
> Firefox/34.0","ip":"203.206.165.208","time":"2014-12-23 13:37:49"} }
> 
> When I test it on my dev environment (localhost) with only one node and  
> there is no load balance applied it works perfect, I always find this "\_id"  
> and the count works pretty good, but on my production with load balance  
> activated I cannot find the results ("\_id") on both servers ws001 and ws002  
> and it breaks my hits counting.
> 
> On my load balance servers I getting completely different results, I mean  
> ("\_id"), when I run: curl –XGET http:  
> //webserver1:9200/stats/listingviews/\_search?pretty and curl –XGET http:  
> //webserver2:9200/stats/listingviews/\_search?pretty. Also I already checked  
> the shads for each server and they are different.
> 
> At the end, the \_ids found on both servers never match and definitely they  
> are not the same ids. I’m supposing that the replica on the load balance is  
> not working as replica and the ES is storing the data in both servers  
> separately. Even if the \_ids are not on each server, the end result should  
> be our ability to count how many records there are (ie. where \_source-\>id =  
> 1159) but it seems to only get a count from ws001.
> 
> Which approach should I take to solve this issue, and be able to count my  
> hits on the production environment?
> 
> Thanks,
> 
> Carlos.
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X-ZdMpsESDq8Dm6MurwmNX2\_xS0oTTHjbMr1Y6KSewViw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X-ZdMpsESDq8Dm6MurwmNX2_xS0oTTHjbMr1Y6KSewViw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Carlos\_Henrique\_de\_O](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Carlos\_Henrique\_de\_O](https://discuss.elastic.co/u/Carlos_Henrique_de_O)\
**Post date:** [January 28, 2015, 4:42am UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/3 "2015-01-28T04:42:54Z")

</div>

Hi Mark,  
Yes, they are two separated nodes.

We are indexing the data via PHP:

public function resetListingsIndex(){  
$es = new Elasticsearch\Client();

```
// delete listings
$deleteParams['index'] = 'listings';
@$es->indices()->delete($deleteParams);

// create listings index
$aElasticSearchParams=array();

$aElasticSearchParams = array(
    'index' => 'listings',
    'body' => array(
        'settings' => array(
            'number_of_shards' => 1,
            'number_of_replicas' => 0,
        ),
        'mappings' => array(
            'listing' => array(
                'properties' => array(
                    'reference_number' => array(
                        'type' => 'integer',
                        'analyzer' => 'keyword',
                    ),
                    'headline' => array(
                        "analyzer" => "standard",
                        "type" => "string",

                    ),
                    'headline' => array(
                        "analyzer" => "standard",
                        "type" => "string",

                    ),
                    'type' => array(
                        'type' => 'string',
                        'analyzer' => 'standard',
                    ),
                    'state' => array(
                        'type' => 'string',
                        'analyzer' => 'standard',

                    ),
                    //all other properties...
                )
            )
        )
    )

);

try{
    $aResult=$es->indices()->create($aElasticSearchParams);
    if($aResult['acknowledged']==true){
        return 'Successfully indexed';
    }
}
catch(Exception $e){
    return $e;
}

```

}

And yes we are using the auto ID generation within ES

Em quarta-feira, 28 de janeiro de 2015 12:06:51 UTC+11, Mark Walkom  
escreveu:

> So these two nodes are their own separate clusters?  
> How are you indexing data into them? Are you using the auto ID generation  
> within ES or specifying your own?
> 
> On 28 January 2015 at 11:56, Carlos Henrique de Oliveira \<  
> [cholive...@gmail.com](mailto:cholive...@gmail.com) \<javascript:\>\> wrote:
> 
> > I have two Web Servers ws001 and ws002 working as load balance for  
> > Elasticseach and I am trying to catch/count the hits for a specific page  
> > which is something like this: [mysite.com/listing/item-123/](http://mysite.com/listing/item-123/).
> > 
> > Using the ES I am running curl –XGET http: //  
> > [mysite.com:9200/stats/listingviews/\_search?pretty](http://mysite.com:9200/stats/listingviews/_search?pretty) Then count the hits  
> > for a specific "\_id": "hits" : { "total" : 1526, "max\_score" : 1.0, "hits"  
> > : [ { "\_index" : "stats", "\_type" : "listingviews", "\_id" :  
> > "IYSs1OmqSvK6gRDQr61j3w", "\_score" : 1.0,  
> > "\_source":{"id":"1159","type":"listing","ua":"Mozilla/5.0 (Windows NT 6.1;  
> > WOW64; rv:34.0) Gecko/20100101  
> > Firefox/34.0","ip":"203.206.165.208","time":"2014-12-23 13:37:49"} }
> > 
> > When I test it on my dev environment (localhost) with only one node and  
> > there is no load balance applied it works perfect, I always find this "\_id"  
> > and the count works pretty good, but on my production with load balance  
> > activated I cannot find the results ("\_id") on both servers ws001 and ws002  
> > and it breaks my hits counting.
> > 
> > On my load balance servers I getting completely different results, I mean  
> > ("\_id"), when I run: curl –XGET http:  
> > //webserver1:9200/stats/listingviews/\_search?pretty and curl –XGET http:  
> > //webserver2:9200/stats/listingviews/\_search?pretty. Also I already checked  
> > the shads for each server and they are different.
> > 
> > At the end, the \_ids found on both servers never match and definitely  
> > they are not the same ids. I’m supposing that the replica on the load  
> > balance is not working as replica and the ES is storing the data in both  
> > servers separately. Even if the \_ids are not on each server, the end result  
> > should be our ability to count how many records there are (ie. where  
> > \_source-\>id = 1159) but it seems to only get a count from ws001.
> > 
> > Which approach should I take to solve this issue, and be able to count my  
> > hits on the production environment?
> > 
> > Thanks,
> > 
> > Carlos.
> > 
> > --  
> > 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](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 28, 2015, 5:36am UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/4 "2015-01-28T05:36:57Z")

</div>

They are separate nodes, but are they in the same cluster, or are they  
running as their own unique clusters? ie you have two clusters of one node  
each, rather than one cluster with two nodes.

On 28 January 2015 at 15:42, Carlos Henrique de Oliveira \<  
[choliveira0604@gmail.com](mailto:choliveira0604@gmail.com)\> wrote:

> Hi Mark,  
> Yes, they are two separated nodes.
> 
> We are indexing the data via PHP:
> 
> public function resetListingsIndex(){  
> $es = new Elasticsearch\Client();
> 
> ```
> // delete listings
> $deleteParams['index'] = 'listings';
> @$es->indices()->delete($deleteParams);
> 
> // create listings index
> $aElasticSearchParams=array();
> 
> $aElasticSearchParams = array(
> 'index' => 'listings',
> 'body' => array(
> 'settings' => array(
> 'number_of_shards' => 1,
> 'number_of_replicas' => 0,
> ),
> 'mappings' => array(
> 'listing' => array(
> 'properties' => array(
> 'reference_number' => array(
> 'type' => 'integer',
> 'analyzer' => 'keyword',
> ),
> 'headline' => array(
> "analyzer" => "standard",
> "type" => "string",
> 
> ),
> 'headline' => array(
> "analyzer" => "standard",
> "type" => "string",
> 
> ),
> 'type' => array(
> 'type' => 'string',
> 'analyzer' => 'standard',
> ),
> 'state' => array(
> 'type' => 'string',
> 'analyzer' => 'standard',
> 
> ),
> //all other properties...
> )
> )
> )
> )
> 
> );
> 
> try{
> $aResult=$es->indices()->create($aElasticSearchParams);
> if($aResult['acknowledged']==true){
> return 'Successfully indexed';
> }
> }
> catch(Exception $e){
> return $e;
> }
> 
> ```
> 
> }
> 
> And yes we are using the auto ID generation within ES
> 
> Em quarta-feira, 28 de janeiro de 2015 12:06:51 UTC+11, Mark Walkom  
> escreveu:
> 
> > So these two nodes are their own separate clusters?  
> > How are you indexing data into them? Are you using the auto ID generation  
> > within ES or specifying your own?
> > 
> > On 28 January 2015 at 11:56, Carlos Henrique de Oliveira \<  
> > [cholive...@gmail.com](mailto:cholive...@gmail.com)\> wrote:
> > 
> > > I have two Web Servers ws001 and ws002 working as load balance for  
> > > Elasticseach and I am trying to catch/count the hits for a specific page  
> > > which is something like this: [mysite.com/listing/item-123/](http://mysite.com/listing/item-123/).
> > > 
> > > Using the ES I am running curl –XGET http: [//mysite.com:9200/stats/](https://mysite.com:9200/stats/)  
> > > listingviews/\_search?pretty Then count the hits for a specific "\_id":  
> > > "hits" : { "total" : 1526, "max\_score" : 1.0, "hits" : [ { "\_index" :  
> > > "stats", "\_type" : "listingviews", "\_id" : "IYSs1OmqSvK6gRDQr61j3w",  
> > > "\_score" : 1.0, "\_source":{"id":"1159","type":"listing","ua":"Mozilla/5.0  
> > > (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0","ip":"203.206.165.208","time":"2014-12-23  
> > > 13:37:49"} }
> > > 
> > > When I test it on my dev environment (localhost) with only one node and  
> > > there is no load balance applied it works perfect, I always find this "\_id"  
> > > and the count works pretty good, but on my production with load balance  
> > > activated I cannot find the results ("\_id") on both servers ws001 and ws002  
> > > and it breaks my hits counting.
> > > 
> > > On my load balance servers I getting completely different results, I  
> > > mean ("\_id"), when I run: curl –XGET http: //webserver1:9200/stats/listingviews/\_search?pretty  
> > > and curl –XGET http: //webserver2:9200/stats/listingviews/\_search?pretty.  
> > > Also I already checked the shads for each server and they are different.
> > > 
> > > At the end, the \_ids found on both servers never match and definitely  
> > > they are not the same ids. I’m supposing that the replica on the load  
> > > balance is not working as replica and the ES is storing the data in both  
> > > servers separately. Even if the \_ids are not on each server, the end result  
> > > should be our ability to count how many records there are (ie. where  
> > > \_source-\>id = 1159) but it seems to only get a count from ws001.
> > > 
> > > Which approach should I take to solve this issue, and be able to count  
> > > my hits on the production environment?
> > > 
> > > Thanks,
> > > 
> > > Carlos.
> > > 
> > > --  
> > > 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](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X-Se8W7%2BVoYOmnrqw%3DXZQZG172SgJ7Hu038dp0%3DpXjXPg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X-Se8W7%2BVoYOmnrqw%3DXZQZG172SgJ7Hu038dp0%3DpXjXPg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Carlos\_Henrique\_de\_O](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@Carlos\_Henrique\_de\_O](https://discuss.elastic.co/u/Carlos_Henrique_de_O)\
**Post date:** [January 28, 2015, 9:36pm UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/5 "2015-01-28T21:36:22Z")

</div>

They are two Closters WS0001 and WS001 of one node each. In each server we  
have a node like this:

WS001 =\> node.name: "elasticsearch\_node\_ws001"

WS002 =\> node.name: "elasticsearch\_node\_ws002"

Thanks.  
Em quarta-feira, 28 de janeiro de 2015 16:37:28 UTC+11, Mark Walkom  
escreveu:

> They are separate nodes, but are they in the same cluster, or are they  
> running as their own unique clusters? ie you have two clusters of one node  
> each, rather than one cluster with two nodes.
> 
> On 28 January 2015 at 15:42, Carlos Henrique de Oliveira \<  
> [cholive...@gmail.com](mailto:cholive...@gmail.com) \<javascript:\>\> wrote:
> 
> > Hi Mark,  
> > Yes, they are two separated nodes.
> > 
> > We are indexing the data via PHP:
> > 
> > public function resetListingsIndex(){  
> > $es = new Elasticsearch\Client();
> > 
> > ```
> > // delete listings
> > $deleteParams['index'] = 'listings';
> > @$es->indices()->delete($deleteParams);
> > 
> > // create listings index
> > $aElasticSearchParams=array();
> > 
> > $aElasticSearchParams = array(
> > 'index' => 'listings',
> > 'body' => array(
> > 'settings' => array(
> > 'number_of_shards' => 1,
> > 'number_of_replicas' => 0,
> > ),
> > 'mappings' => array(
> > 'listing' => array(
> > 'properties' => array(
> > 'reference_number' => array(
> > 'type' => 'integer',
> > 'analyzer' => 'keyword',
> > ),
> > 'headline' => array(
> > "analyzer" => "standard",
> > "type" => "string",
> > 
> > ),
> > 'headline' => array(
> > "analyzer" => "standard",
> > "type" => "string",
> > 
> > ),
> > 'type' => array(
> > 'type' => 'string',
> > 'analyzer' => 'standard',
> > ),
> > 'state' => array(
> > 'type' => 'string',
> > 'analyzer' => 'standard',
> > 
> > ),
> > //all other properties...
> > )
> > )
> > )
> > )
> > 
> > );
> > 
> > try{
> > $aResult=$es->indices()->create($aElasticSearchParams);
> > if($aResult['acknowledged']==true){
> > return 'Successfully indexed';
> > }
> > }
> > catch(Exception $e){
> > return $e;
> > }
> > 
> > ```
> > 
> > }
> > 
> > And yes we are using the auto ID generation within ES
> > 
> > Em quarta-feira, 28 de janeiro de 2015 12:06:51 UTC+11, Mark Walkom  
> > escreveu:
> > 
> > > So these two nodes are their own separate clusters?  
> > > How are you indexing data into them? Are you using the auto ID  
> > > generation within ES or specifying your own?
> > > 
> > > On 28 January 2015 at 11:56, Carlos Henrique de Oliveira \<  
> > > [cholive...@gmail.com](mailto:cholive...@gmail.com)\> wrote:
> > > 
> > > > I have two Web Servers ws001 and ws002 working as load balance for  
> > > > Elasticseach and I am trying to catch/count the hits for a specific page  
> > > > which is something like this: [mysite.com/listing/item-123/](http://mysite.com/listing/item-123/).
> > > > 
> > > > Using the ES I am running curl –XGET http: [//mysite.com:9200/stats/](https://mysite.com:9200/stats/)  
> > > > listingviews/\_search?pretty Then count the hits for a specific "\_id":  
> > > > "hits" : { "total" : 1526, "max\_score" : 1.0, "hits" : [ { "\_index" :  
> > > > "stats", "\_type" : "listingviews", "\_id" : "IYSs1OmqSvK6gRDQr61j3w",  
> > > > "\_score" : 1.0, "\_source":{"id":"1159","type":"listing","ua":"Mozilla/5.0  
> > > > (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0","ip":"203.206.165.208","time":"2014-12-23  
> > > > 13:37:49"} }
> > > > 
> > > > When I test it on my dev environment (localhost) with only one node and  
> > > > there is no load balance applied it works perfect, I always find this "\_id"  
> > > > and the count works pretty good, but on my production with load balance  
> > > > activated I cannot find the results ("\_id") on both servers ws001 and ws002  
> > > > and it breaks my hits counting.
> > > > 
> > > > On my load balance servers I getting completely different results, I  
> > > > mean ("\_id"), when I run: curl –XGET http: //webserver1:9200/stats/listingviews/\_search?pretty  
> > > > and curl –XGET http: //webserver2:9200/stats/listingviews/\_search?pretty.  
> > > > Also I already checked the shads for each server and they are different.
> > > > 
> > > > At the end, the \_ids found on both servers never match and definitely  
> > > > they are not the same ids. I’m supposing that the replica on the load  
> > > > balance is not working as replica and the ES is storing the data in both  
> > > > servers separately. Even if the \_ids are not on each server, the end result  
> > > > should be our ability to count how many records there are (ie. where  
> > > > \_source-\>id = 1159) but it seems to only get a count from ws001.
> > > > 
> > > > Which approach should I take to solve this issue, and be able to count  
> > > > my hits on the production environment?
> > > > 
> > > > Thanks,
> > > > 
> > > > Carlos.
> > > > 
> > > > --  
> > > > 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](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9bf9bc38-44cb-4538-8c12-83240d4d509c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9bf9bc38-44cb-4538-8c12-83240d4d509c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 28, 2015, 10:53pm UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/6 "2015-01-28T22:53:02Z")

</div>

By default \_id is auto generated by Elasticsearch -  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/index-doc.html#_autogenerating_ids).  
It's done using a method similar to this  
[http://www.boundary.com/blog/2012/01/flake-a-decentralized-k-ordered-unique-id-generator-in-erlang/](http://www.boundary.com/blog/2012/01/flake-a-decentralized-k-ordered-unique-id-generator-in-erlang/)

Given you have two distinct clusters, I'd expect that the id's would be  
different.

How are you load balancing across these two clusters?

On 29 January 2015 at 08:36, Carlos Henrique de Oliveira \<  
[choliveira0604@gmail.com](mailto:choliveira0604@gmail.com)\> wrote:

> They are two Closters WS0001 and WS001 of one node each. In each server we  
> have a node like this:
> 
> WS001 =\> node.name: "elasticsearch\_node\_ws001"
> 
> WS002 =\> node.name: "elasticsearch\_node\_ws002"
> 
> Thanks.  
> Em quarta-feira, 28 de janeiro de 2015 16:37:28 UTC+11, Mark Walkom  
> escreveu:
> 
> > They are separate nodes, but are they in the same cluster, or are they  
> > running as their own unique clusters? ie you have two clusters of one node  
> > each, rather than one cluster with two nodes.
> > 
> > On 28 January 2015 at 15:42, Carlos Henrique de Oliveira \<  
> > [cholive...@gmail.com](mailto:cholive...@gmail.com)\> wrote:
> > 
> > > Hi Mark,  
> > > Yes, they are two separated nodes.
> > > 
> > > We are indexing the data via PHP:
> > > 
> > > public function resetListingsIndex(){  
> > > $es = new Elasticsearch\Client();
> > > 
> > > ```
> > > // delete listings
> > > $deleteParams['index'] = 'listings';
> > > @$es->indices()->delete($deleteParams);
> > > 
> > > // create listings index
> > > $aElasticSearchParams=array();
> > > 
> > > $aElasticSearchParams = array(
> > > 'index' => 'listings',
> > > 'body' => array(
> > > 'settings' => array(
> > > 'number_of_shards' => 1,
> > > 'number_of_replicas' => 0,
> > > ),
> > > 'mappings' => array(
> > > 'listing' => array(
> > > 'properties' => array(
> > > 'reference_number' => array(
> > > 'type' => 'integer',
> > > 'analyzer' => 'keyword',
> > > ),
> > > 'headline' => array(
> > > "analyzer" => "standard",
> > > "type" => "string",
> > > 
> > > ),
> > > 'headline' => array(
> > > "analyzer" => "standard",
> > > "type" => "string",
> > > 
> > > ),
> > > 'type' => array(
> > > 'type' => 'string',
> > > 'analyzer' => 'standard',
> > > ),
> > > 'state' => array(
> > > 'type' => 'string',
> > > 'analyzer' => 'standard',
> > > 
> > > ),
> > > //all other properties...
> > > )
> > > )
> > > )
> > > )
> > > 
> > > );
> > > 
> > > try{
> > > $aResult=$es->indices()->create($aElasticSearchParams);
> > > if($aResult['acknowledged']==true){
> > > return 'Successfully indexed';
> > > }
> > > }
> > > catch(Exception $e){
> > > return $e;
> > > }
> > > 
> > > ```
> > > 
> > > }
> > > 
> > > And yes we are using the auto ID generation within ES
> > > 
> > > Em quarta-feira, 28 de janeiro de 2015 12:06:51 UTC+11, Mark Walkom  
> > > escreveu:
> > > 
> > > > So these two nodes are their own separate clusters?  
> > > > How are you indexing data into them? Are you using the auto ID  
> > > > generation within ES or specifying your own?
> > > > 
> > > > On 28 January 2015 at 11:56, Carlos Henrique de Oliveira \<  
> > > > [cholive...@gmail.com](mailto:cholive...@gmail.com)\> wrote:
> > > > 
> > > > > I have two Web Servers ws001 and ws002 working as load balance for  
> > > > > Elasticseach and I am trying to catch/count the hits for a specific page  
> > > > > which is something like this: [mysite.com/listing/item-123/](http://mysite.com/listing/item-123/).
> > > > > 
> > > > > Using the ES I am running curl –XGET http: [//mysite.com:9200/stats/](https://mysite.com:9200/stats/)  
> > > > > listingviews/\_search?pretty Then count the hits for a specific "\_id":  
> > > > > "hits" : { "total" : 1526, "max\_score" : 1.0, "hits" : [ { "\_index" :  
> > > > > "stats", "\_type" : "listingviews", "\_id" : "IYSs1OmqSvK6gRDQr61j3w",  
> > > > > "\_score" : 1.0, "\_source":{"id":"1159","type":"listing","ua":"Mozilla/5.0  
> > > > > (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0","ip":"203.206.  
> > > > > 165.208","time":"2014-12-23 13:37:49"} }
> > > > > 
> > > > > When I test it on my dev environment (localhost) with only one node  
> > > > > and there is no load balance applied it works perfect, I always find this  
> > > > > "\_id" and the count works pretty good, but on my production with load  
> > > > > balance activated I cannot find the results ("\_id") on both servers ws001  
> > > > > and ws002 and it breaks my hits counting.
> > > > > 
> > > > > On my load balance servers I getting completely different results, I  
> > > > > mean ("\_id"), when I run: curl –XGET http: //webserver1:9200/stats/  
> > > > > listingviews/\_search?pretty and curl –XGET http:  
> > > > > //webserver2:9200/stats/listingviews/\_search?pretty. Also I already  
> > > > > checked the shads for each server and they are different.
> > > > > 
> > > > > At the end, the \_ids found on both servers never match and definitely  
> > > > > they are not the same ids. I’m supposing that the replica on the load  
> > > > > balance is not working as replica and the ES is storing the data in both  
> > > > > servers separately. Even if the \_ids are not on each server, the end result  
> > > > > should be our ability to count how many records there are (ie. where  
> > > > > \_source-\>id = 1159) but it seems to only get a count from ws001.
> > > > > 
> > > > > Which approach should I take to solve this issue, and be able to count  
> > > > > my hits on the production environment?
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > Carlos.
> > > > > 
> > > > > --  
> > > > > 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](mailto:elasticsearc...@googlegroups.com).  
> > > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > > msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40goo  
> > > > > [glegroups.com](http://glegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9f7133f7-3bbb-4b7b-b298-d4bd125baf34%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > > .  
> > > > > For more options, visit [https://groups.google.com/d/optout](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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8bb1a8b7-6972-49d3-8930-0ee50556ef8a%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .  
> > > > For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/9bf9bc38-44cb-4538-8c12-83240d4d509c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9bf9bc38-44cb-4538-8c12-83240d4d509c%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/9bf9bc38-44cb-4538-8c12-83240d4d509c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9bf9bc38-44cb-4538-8c12-83240d4d509c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAEYi1X8vgz%2B7X7YQF1\_LkCZe8xDnz8UNFiG2arpcAWJAdLiS7w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAEYi1X8vgz%2B7X7YQF1_LkCZe8xDnz8UNFiG2arpcAWJAdLiS7w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:36am UTC](https://discuss.elastic.co/t/elasticseach-is-not-matching--id-between-the-clusters/21865/7 "2017-07-06T00:36:03Z")

</div>


