# Elasticsearch still scan all types in a index even if I specify a type

**URL:** <https://discuss.elastic.co/t/elasticsearch-still-scan-all-types-in-a-index-even-if-i-specify-a-type/18996>\
**Category:** Elasticsearch\
**Created:** [July 31, 2014, 3:58am UTC](https://discuss.elastic.co/t/elasticsearch-still-scan-all-types-in-a-index-even-if-i-specify-a-type/18996 "2014-07-31T03:58:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11149](https://avatars.discourse-cdn.com/v4/letter/1/da6949/32.png) [@11149](https://discuss.elastic.co/u/11149)\
**Post date:** [July 31, 2014, 3:58am UTC](https://discuss.elastic.co/t/elasticsearch-still-scan-all-types-in-a-index-even-if-i-specify-a-type/18996/1 "2014-07-31T03:58:46Z")

</div>

First, put some sample data:

curl -XPUT 'localhost:9200/testindex/action1/1?pretty' -d '  
{  
"title": "jumping tom",  
"val": 101  
}'

curl -XPUT 'localhost:9200/testindex/action2/1?pretty' -d '  
{  
"title": "jumping jerry",  
"val": "test"  
}'

as you can see, and the mapping is :

{  
"action1" : {  
"properties" : {  
"val" : {  
"type" : "long"  
},  
"title" : {  
"type" : "string"  
}  
}  
},  
"action2" : {  
"properties" : {  
"val" : {  
"type" : "string"  
},  
"title" : {  
"type" : "string"  
}  
}  
}  
}

But when do a aggs action:

curl '[http://192.168.2.245:9200/testindex/action1/\_search](http://192.168.2.245:9200/testindex/action1/_search)' -d '  
{  
"aggs": {  
"vals": {  
"terms": {  
"field": "val"  
}  
}  
}  
}'

{  
"took" : 37,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 4,  
"failed" : 1,  
"failures" : [  
{  
"index" : "testindex",  
"shard" : 2,  
"status" : 500,  
"reason" : "RemoteTransportException[[a00][inet[/192.168.2.246:9300]][search/phase/query]];  
nested: ElasticsearchException[java.lang.NumberFormatException: Invalid  
shift value (84) in prefixCoded bytes (is encoded value really an INT?)];  
nested: UncheckedExecutionException[java.lang.NumberFormatException:  
Invalid shift value (84) in prefixCoded bytes (is encoded value really an  
INT?)]; nested: NumberFormatException[Invalid shift value (84) in  
prefixCoded bytes (is encoded value really an INT?)]; "  
}  
]  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : [  
]  
},  
"aggregations" : {  
"vals" : {  
"buckets" : [  
]  
}  
}  
}

The val field in action1 type is mapped to long, but it seems that ES still  
scan the action2 type even if I specify the action1 type.

## any advice to resolve this issue ? thanks.

不学习，不知道

--  
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/CA%2BJstLB\_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [July 31, 2014, 4:55pm UTC](https://discuss.elastic.co/t/elasticsearch-still-scan-all-types-in-a-index-even-if-i-specify-a-type/18996/2 "2014-07-31T16:55:26Z")

</div>

All types eventually belong to the same Lucene index and Lucene cannot  
handle different types for the same field name. Avoid using the same name  
across types if the field type is different.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--  
Ivan

On Wed, Jul 30, 2014 at 8:58 PM, panfei [cnweike@gmail.com](mailto:cnweike@gmail.com) wrote:

> First, put some sample data:
> 
> curl -XPUT 'localhost:9200/testindex/action1/1?pretty' -d '  
> {  
> "title": "jumping tom",  
> "val": 101  
> }'
> 
> curl -XPUT 'localhost:9200/testindex/action2/1?pretty' -d '  
> {  
> "title": "jumping jerry",  
> "val": "test"  
> }'
> 
> as you can see, and the mapping is :
> 
> {  
> "action1" : {  
> "properties" : {  
> "val" : {  
> "type" : "long"  
> },  
> "title" : {  
> "type" : "string"  
> }  
> }  
> },  
> "action2" : {  
> "properties" : {  
> "val" : {  
> "type" : "string"  
> },  
> "title" : {  
> "type" : "string"  
> }  
> }  
> }  
> }
> 
> But when do a aggs action:
> 
> curl '[http://192.168.2.245:9200/testindex/action1/\_search](http://192.168.2.245:9200/testindex/action1/_search)' -d '  
> {  
> "aggs": {  
> "vals": {  
> "terms": {  
> "field": "val"  
> }  
> }  
> }  
> }'
> 
> {  
> "took" : 37,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 4,  
> "failed" : 1,  
> "failures" : [  
> {  
> "index" : "testindex",  
> "shard" : 2,  
> "status" : 500,  
> "reason" : "RemoteTransportException[[a00][inet[/192.168.2.246:9300]][search/phase/query]];  
> nested: ElasticsearchException[java.lang.NumberFormatException: Invalid  
> shift value (84) in prefixCoded bytes (is encoded value really an INT?)];  
> nested: UncheckedExecutionException[java.lang.NumberFormatException:  
> Invalid shift value (84) in prefixCoded bytes (is encoded value really an  
> INT?)]; nested: NumberFormatException[Invalid shift value (84) in  
> prefixCoded bytes (is encoded value really an INT?)]; "  
> }  
> ]  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" : [  
> ]  
> },  
> "aggregations" : {  
> "vals" : {  
> "buckets" : [  
> ]  
> }  
> }  
> }
> 
> The val field in action1 type is mapped to long, but it seems that ES  
> still scan the action2 type even if I specify the action1 type.
> 
> ## any advice to resolve this issue ? thanks.
> 
> 不学习，不知道
> 
> --  
> 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/CA%2BJstLB\_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB\_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.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/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8\_zgBGA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8_zgBGA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11149](https://avatars.discourse-cdn.com/v4/letter/1/da6949/32.png) [@11149](https://discuss.elastic.co/u/11149)\
**Post date:** [August 7, 2014, 1:49am UTC](https://discuss.elastic.co/t/elasticsearch-still-scan-all-types-in-a-index-even-if-i-specify-a-type/18996/3 "2014-08-07T01:49:53Z")

</div>

Thanks for the information

2014-08-01 0:55 GMT+08:00 Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com):

> All types eventually belong to the same Lucene index and Lucene cannot  
> handle different types for the same field name. Avoid using the same name  
> across types if the field type is different.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#_avoiding_type_gotchas)
> 
> --  
> Ivan
> 
> On Wed, Jul 30, 2014 at 8:58 PM, panfei [cnweike@gmail.com](mailto:cnweike@gmail.com) wrote:
> 
> > First, put some sample data:
> > 
> > curl -XPUT 'localhost:9200/testindex/action1/1?pretty' -d '  
> > {  
> > "title": "jumping tom",  
> > "val": 101  
> > }'
> > 
> > curl -XPUT 'localhost:9200/testindex/action2/1?pretty' -d '  
> > {  
> > "title": "jumping jerry",  
> > "val": "test"  
> > }'
> > 
> > as you can see, and the mapping is :
> > 
> > {  
> > "action1" : {  
> > "properties" : {  
> > "val" : {  
> > "type" : "long"  
> > },  
> > "title" : {  
> > "type" : "string"  
> > }  
> > }  
> > },  
> > "action2" : {  
> > "properties" : {  
> > "val" : {  
> > "type" : "string"  
> > },  
> > "title" : {  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }
> > 
> > But when do a aggs action:
> > 
> > curl '[http://192.168.2.245:9200/testindex/action1/\_search](http://192.168.2.245:9200/testindex/action1/_search)' -d '  
> > {  
> > "aggs": {  
> > "vals": {  
> > "terms": {  
> > "field": "val"  
> > }  
> > }  
> > }  
> > }'
> > 
> > {  
> > "took" : 37,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 4,  
> > "failed" : 1,  
> > "failures" : [  
> > {  
> > "index" : "testindex",  
> > "shard" : 2,  
> > "status" : 500,  
> > "reason" : "RemoteTransportException[[a00][inet[/192.168.2.246:9300]][search/phase/query]];  
> > nested: ElasticsearchException[java.lang.NumberFormatException: Invalid  
> > shift value (84) in prefixCoded bytes (is encoded value really an INT?)];  
> > nested: UncheckedExecutionException[java.lang.NumberFormatException:  
> > Invalid shift value (84) in prefixCoded bytes (is encoded value really an  
> > INT?)]; nested: NumberFormatException[Invalid shift value (84) in  
> > prefixCoded bytes (is encoded value really an INT?)]; "  
> > }  
> > ]  
> > },  
> > "hits" : {  
> > "total" : 0,  
> > "max\_score" : null,  
> > "hits" : [  
> > ]  
> > },  
> > "aggregations" : {  
> > "vals" : {  
> > "buckets" : [  
> > ]  
> > }  
> > }  
> > }
> > 
> > The val field in action1 type is mapped to long, but it seems that ES  
> > still scan the action2 type even if I specify the action1 type.
> > 
> > ## any advice to resolve this issue ? thanks.
> > 
> > 不学习，不知道
> > 
> > --  
> > 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/CA%2BJstLB\_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB\_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLB_Md4w49%2BDW2O2OuLY6RBAR0DPz6rHLvb9WcLq8h3n6Q%40mail.gmail.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/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8\_zgBGA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8_zgBGA%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8\_zgBGA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA5e332x7zaZUn9kaFTANL-Pv--%2Buj3ed4a%3DY8_zgBGA%40mail.gmail.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/CA%2BJstLBGD1c2vd%3DYzrw4fCf-0BvXFTfqWmNOJ8bf6wQRHDVaRw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CA%2BJstLBGD1c2vd%3DYzrw4fCf-0BvXFTfqWmNOJ8bf6wQRHDVaRw%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, 1:10am UTC](https://discuss.elastic.co/t/elasticsearch-still-scan-all-types-in-a-index-even-if-i-specify-a-type/18996/4 "2017-07-06T01:10:18Z")

</div>


