# How to save different type in one field?

**URL:** <https://discuss.elastic.co/t/how-to-save-different-type-in-one-field/61209>\
**Category:** Elasticsearch\
**Created:** [September 22, 2016, 7:57am UTC](https://discuss.elastic.co/t/how-to-save-different-type-in-one-field/61209 "2016-09-22T07:57:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WangXiangUSTC](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@WangXiangUSTC](https://discuss.elastic.co/u/WangXiangUSTC)\
**Post date:** [September 22, 2016, 7:57am UTC](https://discuss.elastic.co/t/how-to-save-different-type-in-one-field/61209/1 "2016-09-22T07:57:51Z")

</div>

I send logs to logstash, and then output to elasticsearch. the log is json type.for example：

some like this:  
{"time":"2015-09-22:08:11:22", request:{"url":"192.168.0.1/test","user":"xiang"}}

and others maybe:  
{"time":"2015-09-22:08:11:22", request:{"url":"192.168.0.1/test","user":{"name":"xiang","age":20}}}

In my logstash config file:  
filter {  
json {  
source =\> "message"  
}  
}

so , after deal with the first log, the type of "user" will be string in elasticsearch, but when deal with the second log, the logstash will warn:  
object mapping for [user] tried to parse field [user] as object, but found a concrete value

I know every field in elasticsearch has a type, it is the reason why the second log can't insert into elasticsearch.

My log is json type, and the field's name and type is unknow, it means that I can't deal with every field.  
I have one idea ,if get error when insert, only insert the field "message" to elasticsearch.

so, how to do this ? Or any other ways better ?

---

<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 5, 2017, 10:18pm UTC](https://discuss.elastic.co/t/how-to-save-different-type-in-one-field/61209/2 "2017-07-05T22:18:16Z")

</div>


