# Range query requires mapping type in field spec?

**URL:** <https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439>\
**Category:** Elasticsearch\
**Created:** [November 17, 2013, 8:08am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439 "2013-11-17T08:08:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 17, 2013, 8:08am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/1 "2013-11-17T08:08:11Z")

</div>

Hello,

I have index with numerous mapping types. I'm invoking a search with range  
query and type restriction like this:

$ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
{"bool": {"must": [{"term": {"\_type": "events"}}, {"range": { "timestamp":  
{"to": 1383467660, "include\_upper": false }}}]}}}'  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

It yields zero results although there events with timestamp less  
then 1383467660. Specifying the field as "events.timestamp". Does the trick  
:

$ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
{"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
"events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.4142135,  
"hits" : [ {  
"\_index" : "restful\_copy2",  
"\_type" : "events",  
"\_id" : "1",  
"\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0, "id": 1}  
} ]  
}  
}

However I wonder why does it happen? If I use "id" field in range query, it  
works both ways. The only difference I can spot that id is of type long and  
timestamp is double.

P.S. Elasticsearch 0.90.7.

Thanks,  
Zaar

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 18, 2013, 6:55am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/2 "2013-11-18T06:55:46Z")

</div>

Anyone please?

On Sunday, November 17, 2013 10:08:11 AM UTC+2, Zaar Hai wrote:

> Hello,
> 
> I have index with numerous mapping types. I'm invoking a search with range  
> query and type restriction like this:
> 
> $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
> {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": { "timestamp":  
> {"to": 1383467660, "include\_upper": false }}}]}}}'  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> It yields zero results although there events with timestamp less  
> then 1383467660. Specifying the field as "events.timestamp". Does the trick  
> :
> 
> $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
> {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.4142135,  
> "hits" : [ {  
> "\_index" : "restful\_copy2",  
> "\_type" : "events",  
> "\_id" : "1",  
> "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0, "id":  
> 1}  
> } ]  
> }  
> }
> 
> However I wonder why does it happen? If I use "id" field in range query,  
> it works both ways. The only difference I can spot that id is of type long  
> and timestamp is double.
> 
> P.S. Elasticsearch 0.90.7.
> 
> Thanks,  
> Zaar

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [November 18, 2013, 7:05am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/3 "2013-11-18T07:05:07Z")

</div>

Hi Zaar,

Could you send the following command to ES.  
I think that timestamp field is nested.

curl -XGET localhost:9200/restful/events/\_mapping?pretty

Regards,  
Jun

2013/11/17 Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com)

> Hello,
> 
> I have index with numerous mapping types. I'm invoking a search with range  
> query and type restriction like this:
> 
> $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
> {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": { "timestamp":  
> {"to": 1383467660, "include\_upper": false }}}]}}}'  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> It yields zero results although there events with timestamp less  
> then 1383467660. Specifying the field as "events.timestamp". Does the trick  
> :
> 
> $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
> {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.4142135,  
> "hits" : [ {  
> "\_index" : "restful\_copy2",  
> "\_type" : "events",  
> "\_id" : "1",  
> "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0, "id":  
> 1}  
> } ]  
> }  
> }
> 
> However I wonder why does it happen? If I use "id" field in range query,  
> it works both ways. The only difference I can spot that id is of type long  
> and timestamp is double.
> 
> P.S. Elasticsearch 0.90.7.
> 
> Thanks,  
> Zaar
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

## --

Jun Ohtani  
blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 18, 2013, 7:18am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/4 "2013-11-18T07:18:15Z")

</div>

Thanks Jun,  
The output is below. I use dynamic mapping templates heavily since I have a  
lot of mapping types.

# curl -XGET localhost:9200/restful/events/\_mapping?pretty

{  
"events" : {  
"dynamic\_templates" : [ {  
"template\_string" : {  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"str" : {  
"index\_analyzer" : "substrings",  
"type" : "string"  
},  
"{name}" : {  
"index\_analyzer" : "verbatim",  
"type" : "string"  
}  
}  
},  
"match" : "_",  
"match\_mapping\_type" : "string"  
}  
}, {  
"template\_integer" : {  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"str" : {  
"index\_analyzer" : "substrings",  
"type" : "string"  
},  
"{name}" : {  
"type" : "{dynamic\_type}"  
}  
}  
},  
"match" : "_",  
"match\_mapping\_type" : "integer"  
}  
}, {  
"template\_long" : {  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"str" : {  
"index\_analyzer" : "substrings",  
"type" : "string"  
},  
"{name}" : {  
"type" : "{dynamic\_type}"  
}  
}  
},  
"match" : "_",  
"match\_mapping\_type" : "long"  
}  
}, {  
"template\_double" : {  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"str" : {  
"index\_analyzer" : "substrings",  
"type" : "string"  
},  
"{name}" : {  
"type" : "{dynamic\_type}"  
}  
}  
},  
"match" : "_",  
"match\_mapping\_type" : "double"  
}  
}, {  
"template\_date" : {  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"str" : {  
"index\_analyzer" : "substrings",  
"type" : "string"  
},  
"{name}" : {  
"type" : "{dynamic\_type}"  
}  
}  
},  
"match" : "_",  
"match\_mapping\_type" : "date"  
}  
}, {  
"template\_boolean" : {  
"mapping" : {  
"type" : "multi\_field",  
"fields" : {  
"str" : {  
"index\_analyzer" : "substrings",  
"type" : "string"  
},  
"{name}" : {  
"type" : "{dynamic\_type}"  
}  
}  
},  
"match" : "_",  
"match\_mapping\_type" : "boolean"  
}  
} ],  
"properties" : {  
"id" : {  
"type" : "multi\_field",  
"fields" : {  
"id" : {  
"type" : "long"  
},  
"str" : {  
"type" : "string",  
"index\_analyzer" : "substrings",  
"include\_in\_all" : false  
}  
}  
},  
"timestamp" : {  
"type" : "multi\_field",  
"fields" : {  
"timestamp" : {  
"type" : "double"  
},  
"str" : {  
"type" : "string",  
"index\_analyzer" : "substrings",  
"include\_in\_all" : false  
}  
}  
}  
}  
}  
}

On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:

> Hi Zaar,
> 
> Could you send the following command to ES.  
> I think that timestamp field is nested.
> 
> curl -XGET localhost:9200/restful/events/\_mapping?pretty
> 
> Regards,  
> Jun
> 
> 2013/11/17 Zaar Hai \<[hai...@gmail.com](mailto:hai...@gmail.com) \<javascript:\>\>
> 
> > Hello,
> > 
> > I have index with numerous mapping types. I'm invoking a search with  
> > range query and type restriction like this:
> > 
> > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
> > {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": { "timestamp":  
> > {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > {  
> > "took" : 2,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 1,  
> > "successful" : 1,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 0,  
> > "max\_score" : null,  
> > "hits" :   
> > }  
> > }
> > 
> > It yields zero results although there events with timestamp less  
> > then 1383467660. Specifying the field as "events.timestamp". Does the trick  
> > :
> > 
> > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query":  
> > {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > {  
> > "took" : 2,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 1,  
> > "successful" : 1,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 1,  
> > "max\_score" : 1.4142135,  
> > "hits" : [ {  
> > "\_index" : "restful\_copy2",  
> > "\_type" : "events",  
> > "\_id" : "1",  
> > "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0, "id":  
> > 1}  
> > } ]  
> > }  
> > }
> > 
> > However I wonder why does it happen? If I use "id" field in range query,  
> > it works both ways. The only difference I can spot that id is of type long  
> > and timestamp is double.
> > 
> > P.S. Elasticsearch 0.90.7.
> > 
> > Thanks,  
> > Zaar
> > 
> > --  
> > 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:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [November 18, 2013, 7:45am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/5 "2013-11-18T07:45:02Z")

</div>

Hi,

I try to execute the following gist procedure.  
But I have results both your search request: no prefix and exist prefix.  
Sorry, I don't know why your query to fail...

> <https://gist.github.com/johtani/7524077>

2013/11/18 Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com)

> Thanks Jun,  
> The output is below. I use dynamic mapping templates heavily since I have  
> a lot of mapping types.
> 
> # curl -XGET localhost:9200/restful/events/\_mapping?pretty
> 
> {  
> "events" : {  
> "dynamic\_templates" : [ {  
> "template\_string" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "index\_analyzer" : "verbatim",  
> "type" : "string"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "string"  
> }  
> }, {  
> "template\_integer" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "integer"  
> }  
> }, {  
> "template\_long" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "long"  
> }  
> }, {  
> "template\_double" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "double"  
> }  
> }, {  
> "template\_date" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "date"  
> }  
> }, {  
> "template\_boolean" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "boolean"  
> }  
> } ],  
> "properties" : {  
> "id" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "id" : {  
> "type" : "long"  
> },  
> "str" : {  
> "type" : "string",  
> "index\_analyzer" : "substrings",  
> "include\_in\_all" : false  
> }  
> }  
> },  
> "timestamp" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "timestamp" : {  
> "type" : "double"  
> },  
> "str" : {  
> "type" : "string",  
> "index\_analyzer" : "substrings",  
> "include\_in\_all" : false  
> }  
> }  
> }  
> }  
> }  
> }
> 
> On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:
> 
> > Hi Zaar,
> > 
> > Could you send the following command to ES.  
> > I think that timestamp field is nested.
> > 
> > curl -XGET localhost:9200/restful/events/\_mapping?pretty
> > 
> > Regards,  
> > Jun
> > 
> > 2013/11/17 Zaar Hai [hai...@gmail.com](mailto:hai...@gmail.com)
> > 
> > > Hello,
> > > 
> > > I have index with numerous mapping types. I'm invoking a search with  
> > > range query and type restriction like this:
> > > 
> > > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{  
> > > "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > > "timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > > {  
> > > "took" : 2,  
> > > "timed\_out" : false,  
> > > "\_shards" : {  
> > > "total" : 1,  
> > > "successful" : 1,  
> > > "failed" : 0  
> > > },  
> > > "hits" : {  
> > > "total" : 0,  
> > > "max\_score" : null,  
> > > "hits" :   
> > > }  
> > > }
> > > 
> > > It yields zero results although there events with timestamp less  
> > > then 1383467660. Specifying the field as "events.timestamp". Does the trick  
> > > :
> > > 
> > > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{  
> > > "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > > "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > > {  
> > > "took" : 2,  
> > > "timed\_out" : false,  
> > > "\_shards" : {  
> > > "total" : 1,  
> > > "successful" : 1,  
> > > "failed" : 0  
> > > },  
> > > "hits" : {  
> > > "total" : 1,  
> > > "max\_score" : 1.4142135,  
> > > "hits" : [ {  
> > > "\_index" : "restful\_copy2",  
> > > "\_type" : "events",  
> > > "\_id" : "1",  
> > > "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0,  
> > > "id": 1}  
> > > } ]  
> > > }  
> > > }
> > > 
> > > However I wonder why does it happen? If I use "id" field in range query,  
> > > it works both ways. The only difference I can spot that id is of type long  
> > > and timestamp is double.
> > > 
> > > P.S. Elasticsearch 0.90.7.
> > > 
> > > Thanks,  
> > > Zaar
> > > 
> > > --  
> > > 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).
> > > 
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > ## --
> > 
> > Jun Ohtani  
> > blog : [http://blog.johtani.info](http://blog.johtani.info)
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

## --

Jun Ohtani  
blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 19, 2013, 9:18am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/6 "2013-11-19T09:18:28Z")

</div>

Thanks for an attempt Jun,

I've dug it further and the problem is that I have another mapping type  
that also has a timestamp field with type long. However I still did not  
succeed reproducing it in a small isolated code.

On Monday, November 18, 2013 9:45:02 AM UTC+2, Jun Ohtani wrote:

> Hi,
> 
> I try to execute the following gist procedure.  
> But I have results both your search request: no prefix and exist prefix.  
> Sorry, I don't know why your query to fail...
> 
> [I execute "sample\_exec.json" step by step. I receive response both requests: no prefix and exists prefix. · GitHub](https://gist.github.com/johtani/7524077)
> 
> 2013/11/18 Zaar Hai \<[hai...@gmail.com](mailto:hai...@gmail.com) \<javascript:\>\>
> 
> > Thanks Jun,  
> > The output is below. I use dynamic mapping templates heavily since I have  
> > a lot of mapping types.
> > 
> > # curl -XGET localhost:9200/restful/events/\_mapping?pretty
> > 
> > {  
> > "events" : {  
> > "dynamic\_templates" : [ {  
> > "template\_string" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "index\_analyzer" : "verbatim",  
> > "type" : "string"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "string"  
> > }  
> > }, {  
> > "template\_integer" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "integer"  
> > }  
> > }, {  
> > "template\_long" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "long"  
> > }  
> > }, {  
> > "template\_double" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "double"  
> > }  
> > }, {  
> > "template\_date" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "date"  
> > }  
> > }, {  
> > "template\_boolean" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "boolean"  
> > }  
> > } ],  
> > "properties" : {  
> > "id" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "id" : {  
> > "type" : "long"  
> > },  
> > "str" : {  
> > "type" : "string",  
> > "index\_analyzer" : "substrings",  
> > "include\_in\_all" : false  
> > }  
> > }  
> > },  
> > "timestamp" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "timestamp" : {  
> > "type" : "double"  
> > },  
> > "str" : {  
> > "type" : "string",  
> > "index\_analyzer" : "substrings",  
> > "include\_in\_all" : false  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:
> > 
> > > Hi Zaar,
> > > 
> > > Could you send the following command to ES.  
> > > I think that timestamp field is nested.
> > > 
> > > curl -XGET localhost:9200/restful/events/\_mapping?pretty
> > > 
> > > Regards,  
> > > Jun
> > > 
> > > 2013/11/17 Zaar Hai [hai...@gmail.com](mailto:hai...@gmail.com)
> > > 
> > > > Hello,
> > > > 
> > > > I have index with numerous mapping types. I'm invoking a search with  
> > > > range query and type restriction like this:
> > > > 
> > > > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{  
> > > > "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > > > "timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > > > {  
> > > > "took" : 2,  
> > > > "timed\_out" : false,  
> > > > "\_shards" : {  
> > > > "total" : 1,  
> > > > "successful" : 1,  
> > > > "failed" : 0  
> > > > },  
> > > > "hits" : {  
> > > > "total" : 0,  
> > > > "max\_score" : null,  
> > > > "hits" :   
> > > > }  
> > > > }
> > > > 
> > > > It yields zero results although there events with timestamp less  
> > > > then 1383467660. Specifying the field as "events.timestamp". Does the trick  
> > > > :
> > > > 
> > > > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{  
> > > > "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > > > "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > > > {  
> > > > "took" : 2,  
> > > > "timed\_out" : false,  
> > > > "\_shards" : {  
> > > > "total" : 1,  
> > > > "successful" : 1,  
> > > > "failed" : 0  
> > > > },  
> > > > "hits" : {  
> > > > "total" : 1,  
> > > > "max\_score" : 1.4142135,  
> > > > "hits" : [ {  
> > > > "\_index" : "restful\_copy2",  
> > > > "\_type" : "events",  
> > > > "\_id" : "1",  
> > > > "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0,  
> > > > "id": 1}  
> > > > } ]  
> > > > }  
> > > > }
> > > > 
> > > > However I wonder why does it happen? If I use "id" field in range  
> > > > query, it works both ways. The only difference I can spot that id is of  
> > > > type long and timestamp is double.
> > > > 
> > > > P.S. Elasticsearch 0.90.7.
> > > > 
> > > > Thanks,  
> > > > Zaar
> > > > 
> > > > --  
> > > > 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).
> > > > 
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > 
> > > ## --
> > > 
> > > Jun Ohtani  
> > > blog : [http://blog.johtani.info](http://blog.johtani.info)
> > 
> > --  
> > 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:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [November 19, 2013, 9:29am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/7 "2013-11-19T09:29:21Z")

</div>

Hi Zaar,

I think that your problem is related this section.

> **[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.

Maybe you should use different field name each “mapping type" in the same index.

Regards

* * *

Jun Ohtani  
[johtani@gmail.com](mailto:johtani@gmail.com)  
blog : [http://blog.johtani.info](http://blog.johtani.info)  
twitter : [http://twitter.com/johtani](http://twitter.com/johtani)

2013/11/19 18:18、Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com) のメール：

> Thanks for an attempt Jun,
> 
> I've dug it further and the problem is that I have another mapping type that also has a timestamp field with type long. However I still did not succeed reproducing it in a small isolated code.
> 
> On Monday, November 18, 2013 9:45:02 AM UTC+2, Jun Ohtani wrote:  
> Hi,
> 
> I try to execute the following gist procedure.  
> But I have results both your search request: no prefix and exist prefix.  
> Sorry, I don't know why your query to fail...
> 
> [I execute "sample\_exec.json" step by step. I receive response both requests: no prefix and exists prefix. · GitHub](https://gist.github.com/johtani/7524077)
> 
> 2013/11/18 Zaar Hai [hai...@gmail.com](mailto:hai...@gmail.com)  
> Thanks Jun,  
> The output is below. I use dynamic mapping templates heavily since I have a lot of mapping types.
> 
> # curl -XGET localhost:9200/restful/events/\_mapping?pretty
> 
> {  
> "events" : {  
> "dynamic\_templates" : [ {  
> "template\_string" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "index\_analyzer" : "verbatim",  
> "type" : "string"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "string"  
> }  
> }, {  
> "template\_integer" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "integer"  
> }  
> }, {  
> "template\_long" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "long"  
> }  
> }, {  
> "template\_double" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "double"  
> }  
> }, {  
> "template\_date" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "date"  
> }  
> }, {  
> "template\_boolean" : {  
> "mapping" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "str" : {  
> "index\_analyzer" : "substrings",  
> "type" : "string"  
> },  
> "{name}" : {  
> "type" : "{dynamic\_type}"  
> }  
> }  
> },  
> "match" : "_",  
> "match\_mapping\_type" : "boolean"  
> }  
> } ],  
> "properties" : {  
> "id" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "id" : {  
> "type" : "long"  
> },  
> "str" : {  
> "type" : "string",  
> "index\_analyzer" : "substrings",  
> "include\_in\_all" : false  
> }  
> }  
> },  
> "timestamp" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "timestamp" : {  
> "type" : "double"  
> },  
> "str" : {  
> "type" : "string",  
> "index\_analyzer" : "substrings",  
> "include\_in\_all" : false  
> }  
> }  
> }  
> }  
> }  
> }
> 
> On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:  
> Hi Zaar,
> 
> Could you send the following command to ES.  
> I think that timestamp field is nested.
> 
> curl -XGET localhost:9200/restful/events/\_mapping?pretty
> 
> Regards,  
> Jun
> 
> 2013/11/17 Zaar Hai [hai...@gmail.com](mailto:hai...@gmail.com)  
> Hello,
> 
> I have index with numerous mapping types. I'm invoking a search with range query and type restriction like this:
> 
> $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": { "timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> It yields zero results although there events with timestamp less then 1383467660. Specifying the field as "events.timestamp". Does the trick :
> 
> $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{ "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": { "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 1,  
> "successful" : 1,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.4142135,  
> "hits" : [ {  
> "\_index" : "restful\_copy2",  
> "\_type" : "events",  
> "\_id" : "1",  
> "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0, "id": 1}  
> } ]  
> }  
> }
> 
> However I wonder why does it happen? If I use "id" field in range query, it works both ways. The only difference I can spot that id is of type long and timestamp is double.
> 
> P.S. Elasticsearch 0.90.7.
> 
> Thanks,  
> Zaar
> 
> --  
> 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).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> ## --
> 
> Jun Ohtani  
> blog : [http://blog.johtani.info](http://blog.johtani.info)
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 19, 2013, 1:53pm UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/8 "2013-11-19T13:53:21Z")

</div>

Yeap, that's my case!  
Funny, I remember reading it back in a while...

Thanks for your help Jun!

Zaar

On Tuesday, November 19, 2013 11:29:21 AM UTC+2, Jun Ohtani wrote:

> Hi Zaar,
> 
> I think that your problem is related this section.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html#all-mapping-types)
> 
> Maybe you should use different field name each “mapping type" in the same  
> index.
> 
> Regards
> 
> * * *
> 
> Jun Ohtani  
> [joh...@gmail.com](mailto:joh...@gmail.com) \<javascript:\>  
> blog : [http://blog.johtani.info](http://blog.johtani.info)  
> twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> 
> 2013/11/19 18:18、Zaar Hai \<[hai...@gmail.com](mailto:hai...@gmail.com) \<javascript:\>\> のメール：
> 
> > Thanks for an attempt Jun,
> > 
> > I've dug it further and the problem is that I have another mapping type  
> > that also has a timestamp field with type long. However I still did not  
> > succeed reproducing it in a small isolated code.
> > 
> > On Monday, November 18, 2013 9:45:02 AM UTC+2, Jun Ohtani wrote:  
> > Hi,
> > 
> > I try to execute the following gist procedure.  
> > But I have results both your search request: no prefix and exist prefix.  
> > Sorry, I don't know why your query to fail...
> > 
> > [I execute "sample\_exec.json" step by step. I receive response both requests: no prefix and exists prefix. · GitHub](https://gist.github.com/johtani/7524077)
> > 
> > 2013/11/18 Zaar Hai [hai...@gmail.com](mailto:hai...@gmail.com)  
> > Thanks Jun,  
> > The output is below. I use dynamic mapping templates heavily since I  
> > have a lot of mapping types.
> > 
> > # curl -XGET localhost:9200/restful/events/\_mapping?pretty
> > 
> > {  
> > "events" : {  
> > "dynamic\_templates" : [ {  
> > "template\_string" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "index\_analyzer" : "verbatim",  
> > "type" : "string"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "string"  
> > }  
> > }, {  
> > "template\_integer" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "integer"  
> > }  
> > }, {  
> > "template\_long" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "long"  
> > }  
> > }, {  
> > "template\_double" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "double"  
> > }  
> > }, {  
> > "template\_date" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "date"  
> > }  
> > }, {  
> > "template\_boolean" : {  
> > "mapping" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "str" : {  
> > "index\_analyzer" : "substrings",  
> > "type" : "string"  
> > },  
> > "{name}" : {  
> > "type" : "{dynamic\_type}"  
> > }  
> > }  
> > },  
> > "match" : "_",  
> > "match\_mapping\_type" : "boolean"  
> > }  
> > } ],  
> > "properties" : {  
> > "id" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "id" : {  
> > "type" : "long"  
> > },  
> > "str" : {  
> > "type" : "string",  
> > "index\_analyzer" : "substrings",  
> > "include\_in\_all" : false  
> > }  
> > }  
> > },  
> > "timestamp" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "timestamp" : {  
> > "type" : "double"  
> > },  
> > "str" : {  
> > "type" : "string",  
> > "index\_analyzer" : "substrings",  
> > "include\_in\_all" : false  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > On Monday, November 18, 2013 9:05:07 AM UTC+2, Jun Ohtani wrote:  
> > Hi Zaar,
> > 
> > Could you send the following command to ES.  
> > I think that timestamp field is nested.
> > 
> > curl -XGET localhost:9200/restful/events/\_mapping?pretty
> > 
> > Regards,  
> > Jun
> > 
> > 2013/11/17 Zaar Hai [hai...@gmail.com](mailto:hai...@gmail.com)  
> > Hello,
> > 
> > I have index with numerous mapping types. I'm invoking a search with  
> > range query and type restriction like this:
> > 
> > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{  
> > "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > "timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > {  
> > "took" : 2,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 1,  
> > "successful" : 1,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 0,  
> > "max\_score" : null,  
> > "hits" :   
> > }  
> > }
> > 
> > It yields zero results although there events with timestamp less then  
> > 1383467660. Specifying the field as "events.timestamp". Does the trick :
> > 
> > $ curl -XGET [http://localhost:9200/restful/\_search?pretty](http://localhost:9200/restful/_search?pretty) -d '{  
> > "query": {"bool": {"must": [{"term": {"\_type": "events"}}, {"range": {  
> > "events.timestamp": {"to": 1383467660, "include\_upper": false }}}]}}}'  
> > {  
> > "took" : 2,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 1,  
> > "successful" : 1,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 1,  
> > "max\_score" : 1.4142135,  
> > "hits" : [ {  
> > "\_index" : "restful\_copy2",  
> > "\_type" : "events",  
> > "\_id" : "1",  
> > "\_score" : 1.4142135, "\_source" : {"timestamp": 1383467425.0,  
> > "id": 1}  
> > } ]  
> > }  
> > }
> > 
> > However I wonder why does it happen? If I use "id" field in range query,  
> > it works both ways. The only difference I can spot that id is of type long  
> > and timestamp is double.
> > 
> > P.S. Elasticsearch 0.90.7.
> > 
> > Thanks,  
> > Zaar
> > 
> > --  
> > 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).
> > 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > ## --
> > 
> > Jun Ohtani  
> > blog : [http://blog.johtani.info](http://blog.johtani.info)
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > ## --
> > 
> > Jun Ohtani  
> > blog : [http://blog.johtani.info](http://blog.johtani.info)
> > 
> > --  
> > 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:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:06am UTC](https://discuss.elastic.co/t/range-query-requires-mapping-type-in-field-spec/14439/9 "2017-07-06T02:06:13Z")

</div>


