# Some documents not respecting mapping

**URL:** <https://discuss.elastic.co/t/some-documents-not-respecting-mapping/13877>\
**Category:** Elasticsearch\
**Created:** [October 8, 2013, 1:53pm UTC](https://discuss.elastic.co/t/some-documents-not-respecting-mapping/13877 "2013-10-08T13:53:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Hughes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_hughes/32/2069_2.png) [@Matt\_Hughes](https://discuss.elastic.co/u/Matt_Hughes)\
**Post date:** [October 8, 2013, 1:53pm UTC](https://discuss.elastic.co/t/some-documents-not-respecting-mapping/13877/1 "2013-10-08T13:53:56Z")

</div>

I created a document type with the following mapping:

{

> "access" : {  
> "properties" : {
> 
> - 
> 
> ```
> "body_bytes_sent" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "integer"*
> 
> ```
> 
> - 
> 
> ```
> },*
> "protocol" : {
> "type" : "string"
> },
> "request_method" : {
> "type" : "string"
> },
> 
> ```
> 
> - 
> 
> ```
> "request_time" : {*
> 
> ```
> 
> - 
> 
> ```
> "type" : "float"*
> 
> ```
> 
> - 
> 
> ```
> },*
> "status" : {
> "type" : "string"
> },
> "timestamp" : {
> "type" : "date",
> "format" : "dateOptionalTime"
> },
> "url" : {
> "type" : "string"
> }
> 
> ```
> 
> }  
> }  
> }

I have two documents of this type:

{

> "\_id": "734pPtfbT8iv3rWAo\_IzBg",  
> "\_index": "nginx",  
> "\_source": {
> 
> - "body\_bytes\_sent": 78,\*  
> "protocol": "HTTP/1.1",  
> "request\_method": "GET",
> - "request\_time": 0.035000000000000003,\*  
> "status": "200",  
> "timestamp": "2013-10-07T21:36:01+00:00",  
> "url": "redacted"  
> },  
> "\_type": "access",  
> "\_version": 1,  
> "exists": true  
> }

You can see that _body\_bytes\_sent_ and _request\_time_ both have the correct  
apparent mapping of int and float. But this other document has everything  
as strings:

{

> ```
> "_id": "qAtMiBxpQs6uLdv61Uznpw",
> "_index": "nginx",
> "_source": {
> 
> ```
> 
> - 
> 
> ```
> "body_bytes_sent": "475",*
> "protocol": "HTTP/1.1",
> "request_method": "GET",
> 
> ```
> 
> - 
> 
> ```
> "request_time": "0.088",*
> "status": "200",
> "timestamp": "2013-10-07T21:43:36+00:00",
> "url": "redacted",
> 
> ```
> 
> },  
> "\_type": "access",  
> "\_version": 1,  
> "exists": true  
> }

Now when I try to get the average request time, I get all kinds of problems  
(ClassCastException). I thought that mappings were immutable on a type once  
they were set. How can I make sure my data always has the correct type?

--  
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:** ![Matt\_Hughes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_hughes/32/2069_2.png) [@Matt\_Hughes](https://discuss.elastic.co/u/Matt_Hughes)\
**Post date:** [October 8, 2013, 2:46pm UTC](https://discuss.elastic.co/t/some-documents-not-respecting-mapping/13877/2 "2013-10-08T14:46:37Z")

</div>

Strangely, after several hours all documents started storing in the correct  
format. I guess this resolved itself, but some documents from yesterday are  
still all strings.

On Tuesday, October 8, 2013 9:53:56 AM UTC-4, Matt Hughes wrote:

> I created a document type with the following mapping:
> 
> {
> 
> > "access" : {  
> > "properties" : {
> > 
> > - 
> > 
> > ```
> > "body_bytes_sent" : {*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "type" : "integer"*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > },*
> > "protocol" : {
> > "type" : "string"
> > },
> > "request_method" : {
> > "type" : "string"
> > },
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "request_time" : {*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "type" : "float"*
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > },*
> > "status" : {
> > "type" : "string"
> > },
> > "timestamp" : {
> > "type" : "date",
> > "format" : "dateOptionalTime"
> > },
> > "url" : {
> > "type" : "string"
> > }
> > 
> > ```
> > 
> > }  
> > }  
> > }
> 
> I have two documents of this type:
> 
> {
> 
> > "\_id": "734pPtfbT8iv3rWAo\_IzBg",  
> > "\_index": "nginx",  
> > "\_source": {
> > 
> > - "body\_bytes\_sent": 78,\*  
> > "protocol": "HTTP/1.1",  
> > "request\_method": "GET",
> > - "request\_time": 0.035000000000000003,\*  
> > "status": "200",  
> > "timestamp": "2013-10-07T21:36:01+00:00",  
> > "url": "redacted"  
> > },  
> > "\_type": "access",  
> > "\_version": 1,  
> > "exists": true  
> > }
> 
> You can see that _body\_bytes\_sent_ and _request\_time_ both have the  
> correct apparent mapping of int and float. But this other document has  
> everything as strings:
> 
> {
> 
> > ```
> > "_id": "qAtMiBxpQs6uLdv61Uznpw",
> > "_index": "nginx",
> > "_source": {
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "body_bytes_sent": "475",*
> > "protocol": "HTTP/1.1",
> > "request_method": "GET",
> > 
> > ```
> > 
> > - 
> > 
> > ```
> > "request_time": "0.088",*
> > "status": "200",
> > "timestamp": "2013-10-07T21:43:36+00:00",
> > "url": "redacted",
> > 
> > ```
> > 
> > },  
> > "\_type": "access",  
> > "\_version": 1,  
> > "exists": true  
> > }
> 
> Now when I try to get the average request time, I get all kinds of  
> problems (ClassCastException). I thought that mappings were immutable on a  
> type once they were set. How can I make sure my data always has the correct  
> type?

--  
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:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [October 8, 2013, 3:20pm UTC](https://discuss.elastic.co/t/some-documents-not-respecting-mapping/13877/3 "2013-10-08T15:20:11Z")

</div>

hmm what you are seeing is the "\_source" which is an unprocessed version of  
what you send to ES. Even if you send it as a string we index it as a  
float. The source will still be a string - we don't process it. Is it  
possible that you send it as strings and change over to float?

simon

On Tuesday, October 8, 2013 4:46:37 PM UTC+2, Matt Hughes wrote:

> Strangely, after several hours all documents started storing in the  
> correct format. I guess this resolved itself, but some documents from  
> yesterday are still all strings.
> 
> On Tuesday, October 8, 2013 9:53:56 AM UTC-4, Matt Hughes wrote:
> 
> > I created a document type with the following mapping:
> > 
> > {
> > 
> > > "access" : {  
> > > "properties" : {
> > > 
> > > - 
> > > 
> > > ```
> > > "body_bytes_sent" : {*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "type" : "integer"*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > },*
> > > "protocol" : {
> > > "type" : "string"
> > > },
> > > "request_method" : {
> > > "type" : "string"
> > > },
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "request_time" : {*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "type" : "float"*
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > },*
> > > "status" : {
> > > "type" : "string"
> > > },
> > > "timestamp" : {
> > > "type" : "date",
> > > "format" : "dateOptionalTime"
> > > },
> > > "url" : {
> > > "type" : "string"
> > > }
> > > 
> > > ```
> > > 
> > > }  
> > > }  
> > > }
> > 
> > I have two documents of this type:
> > 
> > {
> > 
> > > "\_id": "734pPtfbT8iv3rWAo\_IzBg",  
> > > "\_index": "nginx",  
> > > "\_source": {
> > > 
> > > - "body\_bytes\_sent": 78,\*  
> > > "protocol": "HTTP/1.1",  
> > > "request\_method": "GET",
> > > - "request\_time": 0.035000000000000003,\*  
> > > "status": "200",  
> > > "timestamp": "2013-10-07T21:36:01+00:00",  
> > > "url": "redacted"  
> > > },  
> > > "\_type": "access",  
> > > "\_version": 1,  
> > > "exists": true  
> > > }
> > 
> > You can see that _body\_bytes\_sent_ and _request\_time_ both have the  
> > correct apparent mapping of int and float. But this other document has  
> > everything as strings:
> > 
> > {
> > 
> > > ```
> > > "_id": "qAtMiBxpQs6uLdv61Uznpw",
> > > "_index": "nginx",
> > > "_source": {
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "body_bytes_sent": "475",*
> > > "protocol": "HTTP/1.1",
> > > "request_method": "GET",
> > > 
> > > ```
> > > 
> > > - 
> > > 
> > > ```
> > > "request_time": "0.088",*
> > > "status": "200",
> > > "timestamp": "2013-10-07T21:43:36+00:00",
> > > "url": "redacted",
> > > 
> > > ```
> > > 
> > > },  
> > > "\_type": "access",  
> > > "\_version": 1,  
> > > "exists": true  
> > > }
> > 
> > Now when I try to get the average request time, I get all kinds of  
> > problems (ClassCastException). I thought that mappings were immutable on a  
> > type once they were set. How can I make sure my data always has the correct  
> > type?

--  
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:13am UTC](https://discuss.elastic.co/t/some-documents-not-respecting-mapping/13877/4 "2017-07-06T02:13:20Z")

</div>


