# Mapping problem

**URL:** <https://discuss.elastic.co/t/mapping-problem/11342>\
**Category:** Elasticsearch\
**Created:** [March 27, 2013, 5:32pm UTC](https://discuss.elastic.co/t/mapping-problem/11342 "2013-03-27T17:32:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jilles\_van\_Gurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jilles_van_gurp/32/879_2.png) [@Jilles\_van\_Gurp](https://discuss.elastic.co/u/Jilles_van_Gurp)\
**Post date:** [March 27, 2013, 5:32pm UTC](https://discuss.elastic.co/t/mapping-problem/11342/1 "2013-03-27T17:32:12Z")

</div>

Hi,

I have a json object with an optional list of link objects with an href and  
couple of optional fields such as type:

{"tags":[{"href":"http:...."}], "anotherfield":"foo"}

That works fine and I can do term queries on tags.href, which is what I  
want.

However, some of my objects don't have tags and in that case the tags field  
is not there. In that case I get a

{"error":"Bad request {"error":"MapperParsingException[object mapping  
for [post] with array for [tags] tried to parse as array, but got EOF, is  
there a mismatch in types for the same field?]","status":400}"}

The mapping for this field is as follows

"tags": {  
"properties": {  
"href": {  
"type": "string",  
"index": "not\_analyzed",  
"omit\_norms": true,  
"index\_options": "docs"  
},  
"type": {  
"type": "string",  
"index": "not\_analyzed",  
"omit\_norms": true,  
"index\_options": "docs"  
}  
}  
}

Is there a way to solve this with my mapping or do I have to provide an  
empty tags array?

--  
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:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 28, 2013, 9:04am UTC](https://discuss.elastic.co/t/mapping-problem/11342/2 "2013-03-28T09:04:58Z")

</div>

Hey Jilles,

I couldnt reproduce the problem with the information available. Can you  
provide a gist and the ES version you are using? Are you maybe mixing up  
types somewhere (one where this mapping is defined, one where it is not?  
Just a rough guess, without being able to look deeper now)

--Alex

On Wed, Mar 27, 2013 at 6:32 PM, Jilles van Gurp [jillesvangurp@gmail.com](mailto:jillesvangurp@gmail.com)wrote:

> Hi,
> 
> I have a json object with an optional list of link objects with an href  
> and couple of optional fields such as type:
> 
> {"tags":[{"href":"http:...."}], "anotherfield":"foo"}
> 
> That works fine and I can do term queries on tags.href, which is what I  
> want.
> 
> However, some of my objects don't have tags and in that case the tags  
> field is not there. In that case I get a
> 
> {"error":"Bad request {"error":"MapperParsingException[object mapping  
> for [post] with array for [tags] tried to parse as array, but got EOF, is  
> there a mismatch in types for the same field?]","status":400}"}
> 
> The mapping for this field is as follows
> 
> "tags": {  
> "properties": {  
> "href": {  
> "type": "string",  
> "index": "not\_analyzed",  
> "omit\_norms": true,  
> "index\_options": "docs"  
> },  
> "type": {  
> "type": "string",  
> "index": "not\_analyzed",  
> "omit\_norms": true,  
> "index\_options": "docs"  
> }  
> }  
> }
> 
> Is there a way to solve this with my mapping or do I have to provide an  
> empty tags array?
> 
> --  
> 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:** ![Jilles\_van\_Gurp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jilles_van_gurp/32/879_2.png) [@Jilles\_van\_Gurp](https://discuss.elastic.co/u/Jilles_van_Gurp)\
**Post date:** [March 28, 2013, 11:39am UTC](https://discuss.elastic.co/t/mapping-problem/11342/3 "2013-03-28T11:39:35Z")

</div>

Hi,

I spend the morning debugging and found the problem. Some of my test code  
was putting an object where a string was supposed to go. So, pilot error  
:-). But thanks for replying.

Jilles

On Thursday, March 28, 2013 10:04:58 AM UTC+1, Alexander Reelsen wrote:

> Hey Jilles,
> 
> I couldnt reproduce the problem with the information available. Can you  
> provide a gist and the ES version you are using? Are you maybe mixing up  
> types somewhere (one where this mapping is defined, one where it is not?  
> Just a rough guess, without being able to look deeper now)
> 
> --Alex
> 
> On Wed, Mar 27, 2013 at 6:32 PM, Jilles van Gurp \<[jilles...@gmail.com](mailto:jilles...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > I have a json object with an optional list of link objects with an href  
> > and couple of optional fields such as type:
> > 
> > {"tags":[{"href":"http:...."}], "anotherfield":"foo"}
> > 
> > That works fine and I can do term queries on tags.href, which is what I  
> > want.
> > 
> > However, some of my objects don't have tags and in that case the tags  
> > field is not there. In that case I get a
> > 
> > {"error":"Bad request {"error":"MapperParsingException[object mapping  
> > for [post] with array for [tags] tried to parse as array, but got EOF, is  
> > there a mismatch in types for the same field?]","status":400}"}
> > 
> > The mapping for this field is as follows
> > 
> > "tags": {  
> > "properties": {  
> > "href": {  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > "omit\_norms": true,  
> > "index\_options": "docs"  
> > },  
> > "type": {  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > "omit\_norms": true,  
> > "index\_options": "docs"  
> > }  
> > }  
> > }
> > 
> > Is there a way to solve this with my mapping or do I have to provide an  
> > empty tags array?
> > 
> > --  
> > 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:43am UTC](https://discuss.elastic.co/t/mapping-problem/11342/4 "2017-07-06T02:43:55Z")

</div>


