# Multi\_field field versus creating 2 separate fields?

**URL:** <https://discuss.elastic.co/t/multi-field-field-versus-creating-2-separate-fields/5620>\
**Category:** Elasticsearch\
**Created:** [October 18, 2011, 6:53am UTC](https://discuss.elastic.co/t/multi-field-field-versus-creating-2-separate-fields/5620 "2011-10-18T06:53:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![datadev](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@datadev](https://discuss.elastic.co/u/datadev)\
**Post date:** [October 18, 2011, 6:53am UTC](https://discuss.elastic.co/t/multi-field-field-versus-creating-2-separate-fields/5620/1 "2011-10-18T06:53:11Z")

</div>

While trying to resolve an issue with querying on multi\_field fields  
([https://groups.google.com/group/elasticsearch/t/1246b63c8a867d](https://groups.google.com/group/elasticsearch/t/1246b63c8a867d)), I  
implemented a workaround by 'flattening' the sub-fields in the multi-  
field into top-level fields. EG: Instead of  
{  
"tweet" : {  
"properties" : {  
"name" : {  
"type" : "multi\_field",  
"fields" : {  
"name" : {"type" : "string", "index" :  
"analyzed"},  
"untouched" : {"type" : "string", "index" :  
"not\_analyzed"}  
}  
}  
}  
}  
}

I now have 2 top-level fields:

{  
"tweet" : {  
"properties" : {  
"name" : {"type" : "string", "index" : "analyzed"},  
"name\_untouched" : {"type" : "string", "index" :  
"not\_analyzed"}  
}  
}  
}

My question is that does it actually make a difference in terms of  
underlying storage efficiency in elasticsearch or runtime query  
performance if I used the multi\_field representation or the 2 separate  
fields representation? EG: Does ES perform any optimizations to make  
multi\_field preferred if it is semantically appropriate? And, if the  
answer is no (there is no difference in performance/efficiency), then  
under what circumstances should multi\_field be used?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 18, 2011, 5:30pm UTC](https://discuss.elastic.co/t/multi-field-field-versus-creating-2-separate-fields/5620/2 "2011-10-18T17:30:56Z")

</div>

The main difference with what you specified, with two explicit mappigns for  
name and name\_untouched, is that you need to repeat the "name" value twice  
in the json, which makes it bigger. The mulit\_field type option reuses the  
same name value in the json.

On Tue, Oct 18, 2011 at 8:53 AM, datadev [nji@adinfocenter.com](mailto:nji@adinfocenter.com) wrote:

> While trying to resolve an issue with querying on multi\_field fields  
> ([https://groups.google.com/group/elasticsearch/t/1246b63c8a867d](https://groups.google.com/group/elasticsearch/t/1246b63c8a867d)), I  
> implemented a workaround by 'flattening' the sub-fields in the multi-  
> field into top-level fields. EG: Instead of  
> {  
> "tweet" : {  
> "properties" : {  
> "name" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "name" : {"type" : "string", "index" :  
> "analyzed"},  
> "untouched" : {"type" : "string", "index" :  
> "not\_analyzed"}  
> }  
> }  
> }  
> }  
> }
> 
> I now have 2 top-level fields:
> 
> {  
> "tweet" : {  
> "properties" : {  
> "name" : {"type" : "string", "index" : "analyzed"},  
> "name\_untouched" : {"type" : "string", "index" :  
> "not\_analyzed"}  
> }  
> }  
> }
> 
> My question is that does it actually make a difference in terms of  
> underlying storage efficiency in elasticsearch or runtime query  
> performance if I used the multi\_field representation or the 2 separate  
> fields representation? EG: Does ES perform any optimizations to make  
> multi\_field preferred if it is semantically appropriate? And, if the  
> answer is no (there is no difference in performance/efficiency), then  
> under what circumstances should multi\_field be used?

---

<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, 3:51am UTC](https://discuss.elastic.co/t/multi-field-field-versus-creating-2-separate-fields/5620/3 "2017-07-06T03:51:33Z")

</div>


