# Proper understanding of routing? Strange results on standard routing

**URL:** <https://discuss.elastic.co/t/proper-understanding-of-routing-strange-results-on-standard-routing/10318>\
**Category:** Elasticsearch\
**Created:** [January 12, 2013, 2:16am UTC](https://discuss.elastic.co/t/proper-understanding-of-routing-strange-results-on-standard-routing/10318 "2013-01-12T02:16:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darius\_Riggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darius_riggins/32/2374_2.png) [@Darius\_Riggins](https://discuss.elastic.co/u/Darius_Riggins)\
**Post date:** [January 12, 2013, 2:16am UTC](https://discuss.elastic.co/t/proper-understanding-of-routing-strange-results-on-standard-routing/10318/1 "2013-01-12T02:16:37Z")

</div>

I'm a little confused by results I'm seeing as far as routing. I set up an  
index, add a routing mapping with required set to true on it, index my  
documents, then do 2 searches, one with routing, the other without, but  
both with a filter set to the routing field, and I get different hit  
counts. I would of expected the routed one to of just been faster, am I not  
understanding correctly? Here's the commands I used to set things up, I did  
a standard bulk index to insert documents into the index.

_Create index_:

curl -XPUT '[http://sscasqaengtv01:9200/deals/](http://sscasqaengtv01:9200/deals/)' -d '  
index :  
number\_of\_shards : 5  
number\_of\_replicas : 1  
'

_Create routing mapping_:

curl -XPUT '[http://sscasqaengtv01:9200/deals/deal/\_mapping](http://sscasqaengtv01:9200/deals/deal/_mapping)' -d '  
{  
"deal" : {  
"\_routing" : {  
"required": true,  
"path": "deal.primaryDivision"  
}  
}  
}  
'

Then I switch the merge.policy.merge\_factor to 30 and the  
index.refresh\_interval to -1, then run a bulk index with around 10 thousand  
documents, each with a primaryDivision entry. Then I reset those index  
settings.

After it's over, I run a flush and optimize command on the index, then I  
run the following searches, expecting the same hit counts, but they are  
different, the non routed one returns far more results than the routed one,  
this doesn't make sense to me with my understanding of routing. What am I  
missing?

_I didn't care about the size, just was looking at hits with and without  
routing specified_:  
curl -XGET  
'[http://sscasqaengtv01:9200/deals/\_search?routing=506f04d5e74bf118145369f3](http://sscasqaengtv01:9200/deals/_search?routing=506f04d5e74bf118145369f3)'  
-d '{

"from": 0, "size": 1,  
"fields": ["\_id"],  
"query": {  
"filtered": { "query": { "term": { "primaryDivision":  
"506f04d5e74bf118145369f3" } } }  
}  
}'

--

---

<div class="post-metadata">

**Author:** ![Darius\_Riggins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/darius_riggins/32/2374_2.png) [@Darius\_Riggins](https://discuss.elastic.co/u/Darius_Riggins)\
**Post date:** [January 14, 2013, 2:40pm UTC](https://discuss.elastic.co/t/proper-understanding-of-routing-strange-results-on-standard-routing/10318/2 "2013-01-14T14:40:51Z")

</div>

I think it may of been due to the mapping needed to be named deals instead  
of deal.

On Friday, January 11, 2013 9:16:37 PM UTC-5, Darius Riggins wrote:

> I'm a little confused by results I'm seeing as far as routing. I set up an  
> index, add a routing mapping with required set to true on it, index my  
> documents, then do 2 searches, one with routing, the other without, but  
> both with a filter set to the routing field, and I get different hit  
> counts. I would of expected the routed one to of just been faster, am I not  
> understanding correctly? Here's the commands I used to set things up, I did  
> a standard bulk index to insert documents into the index.
> 
> _Create index_:
> 
> curl -XPUT '[http://sscasqaengtv01:9200/deals/](http://sscasqaengtv01:9200/deals/)' -d '  
> index :  
> number\_of\_shards : 5  
> number\_of\_replicas : 1  
> '
> 
> _Create routing mapping_:
> 
> curl -XPUT '[http://sscasqaengtv01:9200/deals/deal/\_mapping](http://sscasqaengtv01:9200/deals/deal/_mapping)' -d '  
> {  
> "deal" : {  
> "\_routing" : {  
> "required": true,  
> "path": "deal.primaryDivision"  
> }  
> }  
> }  
> '
> 
> Then I switch the merge.policy.merge\_factor to 30 and the  
> index.refresh\_interval to -1, then run a bulk index with around 10 thousand  
> documents, each with a primaryDivision entry. Then I reset those index  
> settings.
> 
> After it's over, I run a flush and optimize command on the index, then I  
> run the following searches, expecting the same hit counts, but they are  
> different, the non routed one returns far more results than the routed one,  
> this doesn't make sense to me with my understanding of routing. What am I  
> missing?
> 
> _I didn't care about the size, just was looking at hits with and without  
> routing specified_:  
> curl -XGET '  
> [http://sscasqaengtv01:9200/deals/\_search?routing=506f04d5e74bf118145369f3](http://sscasqaengtv01:9200/deals/_search?routing=506f04d5e74bf118145369f3)'  
> -d '{
> 
> "from": 0, "size": 1,  
> "fields": ["\_id"],  
> "query": {  
> "filtered": { "query": { "term": { "primaryDivision":  
> "506f04d5e74bf118145369f3" } } }  
> }  
> }'

--

---

<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, 2:56am UTC](https://discuss.elastic.co/t/proper-understanding-of-routing-strange-results-on-standard-routing/10318/3 "2017-07-06T02:56:39Z")

</div>


