# Fields with same name as recognized types

**URL:** <https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159>\
**Category:** Elasticsearch\
**Created:** [August 8, 2014, 9:14am UTC](https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159 "2014-08-08T09:14:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Octavian](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Octavian](https://discuss.elastic.co/u/Octavian)\
**Post date:** [August 8, 2014, 9:14am UTC](https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159/1 "2014-08-08T09:14:37Z")

</div>

Hy,

I have a problem with fields having the same name as known types. For  
example, I have the following mapping:

{  
"ip\_info" : {  
"properties" : {  
"lat" : {"type" : "double"},  
"long" : {"type" : "double"}  
}  
}  
}

I put the following docs in this field:

{  
"lat":42.3535,  
"long":32.35544545  
}

{  
"lat":41.3535,  
"long":32.35544545  
}

{  
"lat":41.3535,  
"long":32.15544545  
}

When I try to do a top on these fields, the lat is working very good:  
{"aggs":{"top-tags":{"terms":{"field":"lat","size":3}}}}

returns:  
{  
aggregations: {  
top-tags: {  
buckets: [  
{  
key: 41.3535  
doc\_count: 2}  
{  
key: 42.3535  
doc\_count: 1}]}}  
}

But when I try to do a top on "long", the following message is thrown:  
{

- error: ReduceSearchPhaseException[Failed to execute phase [fetch],  
[reduce] ]; nested:  
ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms$Bucket  
cannot be cast to  
org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket];
- status: 503

}

I'm using elasticsearch 1.1.1.

What I'm doing wrong?

Thaank you,

--  
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/8ef2eb7b-10b0-4fe7-9cf2-6b1a99833bbd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8ef2eb7b-10b0-4fe7-9cf2-6b1a99833bbd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 8, 2014, 11:47am UTC](https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159/2 "2014-08-08T11:47:32Z")

</div>

Hi,

I have tried to reproduce your issue on both the master branch and on  
version 1.1.1 but both seem to work as expected. The commands I ran are in  
the following gist:  
[https://gist.github.com/colings86/d67e00c378ee28c4485a](https://gist.github.com/colings86/d67e00c378ee28c4485a)

Could you have a look at let me know if I misunderstood something about  
your problem?

Colin

On Friday, 8 August 2014 10:14:37 UTC+1, Octavian wrote:

> Hy,
> 
> I have a problem with fields having the same name as known types. For  
> example, I have the following mapping:
> 
> {  
> "ip\_info" : {  
> "properties" : {  
> "lat" : {"type" : "double"},  
> "long" : {"type" : "double"}  
> }  
> }  
> }
> 
> I put the following docs in this field:
> 
> {  
> "lat":42.3535,  
> "long":32.35544545  
> }
> 
> {  
> "lat":41.3535,  
> "long":32.35544545  
> }
> 
> {  
> "lat":41.3535,  
> "long":32.15544545  
> }
> 
> When I try to do a top on these fields, the lat is working very good:  
> {"aggs":{"top-tags":{"terms":{"field":"lat","size":3}}}}
> 
> returns:  
> {  
> aggregations: {  
> top-tags: {  
> buckets: [  
> {  
> key: 41.3535  
> doc\_count: 2}  
> {  
> key: 42.3535  
> doc\_count: 1}]}}  
> }
> 
> But when I try to do a top on "long", the following message is thrown:  
> {
> 
> - error: ReduceSearchPhaseException[Failed to execute phase [fetch],  
> [reduce] ]; nested:  
> ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms$Bucket  
> cannot be cast to  
> org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket];
> - status: 503
> 
> }
> 
> I'm using elasticsearch 1.1.1.
> 
> What I'm doing wrong?
> 
> Thaank you,

--  
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/f401b6c0-9af7-4dc1-bb31-d7ab295ef1e7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f401b6c0-9af7-4dc1-bb31-d7ab295ef1e7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Octavian](https://avatars.discourse-cdn.com/v4/letter/o/54ee81/32.png) [@Octavian](https://discuss.elastic.co/u/Octavian)\
**Post date:** [August 11, 2014, 9:12am UTC](https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159/3 "2014-08-11T09:12:05Z")

</div>

Yes, that are the commands that should reproduce this.

If on your version works ok, that my question is why on my setup doing a  
top on long field returns the error (

- error: ReduceSearchPhaseException[Failed to execute phase [fetch],  
[reduce] ]; nested:  
ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms$Bucket  
cannot be cast to  
org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket];

)

Basically, ES tries to convert the fields from double to long. Why is doing  
this?  
On Friday, August 8, 2014 2:47:32 PM UTC+3, Colin Goodheart-Smithe wrote:

> Hi,
> 
> I have tried to reproduce your issue on both the master branch and on  
> version 1.1.1 but both seem to work as expected. The commands I ran are in  
> the following gist:  
> [https://gist.github.com/colings86/d67e00c378ee28c4485a](https://gist.github.com/colings86/d67e00c378ee28c4485a)
> 
> Could you have a look at let me know if I misunderstood something about  
> your problem?
> 
> Colin
> 
> On Friday, 8 August 2014 10:14:37 UTC+1, Octavian wrote:
> 
> > Hy,
> > 
> > I have a problem with fields having the same name as known types. For  
> > example, I have the following mapping:
> > 
> > {  
> > "ip\_info" : {  
> > "properties" : {  
> > "lat" : {"type" : "double"},  
> > "long" : {"type" : "double"}  
> > }  
> > }  
> > }
> > 
> > I put the following docs in this field:
> > 
> > {  
> > "lat":42.3535,  
> > "long":32.35544545  
> > }
> > 
> > {  
> > "lat":41.3535,  
> > "long":32.35544545  
> > }
> > 
> > {  
> > "lat":41.3535,  
> > "long":32.15544545  
> > }
> > 
> > When I try to do a top on these fields, the lat is working very good:  
> > {"aggs":{"top-tags":{"terms":{"field":"lat","size":3}}}}
> > 
> > returns:  
> > {  
> > aggregations: {  
> > top-tags: {  
> > buckets: [  
> > {  
> > key: 41.3535  
> > doc\_count: 2}  
> > {  
> > key: 42.3535  
> > doc\_count: 1}]}}  
> > }
> > 
> > But when I try to do a top on "long", the following message is thrown:  
> > {
> > 
> > - error: ReduceSearchPhaseException[Failed to execute phase [fetch],  
> > [reduce] ]; nested:  
> > ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms$Bucket  
> > cannot be cast to  
> > org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket];
> > - status: 503
> > 
> > }
> > 
> > I'm using elasticsearch 1.1.1.
> > 
> > What I'm doing wrong?
> > 
> > Thaank you,

--  
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/ecd62598-99d4-488f-a749-7597c326d0bd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ecd62598-99d4-488f-a749-7597c326d0bd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 11, 2014, 9:28am UTC](https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159/4 "2014-08-11T09:28:35Z")

</div>

I am not sure why your setup is producing this issue. To help to diagnose  
the cause could you please post the mappings for the index (see [1] for how  
to do this) and the complete cURL command for your search request?

Thanks

Colin

[1] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-mapping.html#indices-get-mapping)

On Monday, 11 August 2014 10:12:05 UTC+1, Octavian wrote:

> Yes, that are the commands that should reproduce this.
> 
> If on your version works ok, that my question is why on my setup doing a  
> top on long field returns the error (
> 
> - error: ReduceSearchPhaseException[Failed to execute phase [fetch],  
> [reduce] ]; nested:  
> ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms$Bucket  
> cannot be cast to  
> org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket];
> 
> )
> 
> Basically, ES tries to convert the fields from double to long. Why is  
> doing this?  
> On Friday, August 8, 2014 2:47:32 PM UTC+3, Colin Goodheart-Smithe wrote:
> 
> > Hi,
> > 
> > I have tried to reproduce your issue on both the master branch and on  
> > version 1.1.1 but both seem to work as expected. The commands I ran are in  
> > the following gist:  
> > [https://gist.github.com/colings86/d67e00c378ee28c4485a](https://gist.github.com/colings86/d67e00c378ee28c4485a)
> > 
> > Could you have a look at let me know if I misunderstood something about  
> > your problem?
> > 
> > Colin
> > 
> > On Friday, 8 August 2014 10:14:37 UTC+1, Octavian wrote:
> > 
> > > Hy,
> > > 
> > > I have a problem with fields having the same name as known types. For  
> > > example, I have the following mapping:
> > > 
> > > {  
> > > "ip\_info" : {  
> > > "properties" : {  
> > > "lat" : {"type" : "double"},  
> > > "long" : {"type" : "double"}  
> > > }  
> > > }  
> > > }
> > > 
> > > I put the following docs in this field:
> > > 
> > > {  
> > > "lat":42.3535,  
> > > "long":32.35544545  
> > > }
> > > 
> > > {  
> > > "lat":41.3535,  
> > > "long":32.35544545  
> > > }
> > > 
> > > {  
> > > "lat":41.3535,  
> > > "long":32.15544545  
> > > }
> > > 
> > > When I try to do a top on these fields, the lat is working very good:  
> > > {"aggs":{"top-tags":{"terms":{"field":"lat","size":3}}}}
> > > 
> > > returns:  
> > > {  
> > > aggregations: {  
> > > top-tags: {  
> > > buckets: [  
> > > {  
> > > key: 41.3535  
> > > doc\_count: 2}  
> > > {  
> > > key: 42.3535  
> > > doc\_count: 1}]}}  
> > > }
> > > 
> > > But when I try to do a top on "long", the following message is thrown:  
> > > {
> > > 
> > > - error: ReduceSearchPhaseException[Failed to execute phase [fetch],  
> > > [reduce] ]; nested:  
> > > ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms$Bucket  
> > > cannot be cast to  
> > > org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket];
> > > - status: 503
> > > 
> > > }
> > > 
> > > I'm using elasticsearch 1.1.1.
> > > 
> > > What I'm doing wrong?
> > > 
> > > Thaank you,

--  
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/6fb2d7c3-8614-453f-b758-dbb4e52d23f7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6fb2d7c3-8614-453f-b758-dbb4e52d23f7%40googlegroups.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:09am UTC](https://discuss.elastic.co/t/fields-with-same-name-as-recognized-types/19159/5 "2017-07-06T01:09:39Z")

</div>


