# Multi\_field mapping

**URL:** <https://discuss.elastic.co/t/multi-field-mapping/14652>\
**Category:** Elasticsearch\
**Created:** [December 1, 2013, 2:04pm UTC](https://discuss.elastic.co/t/multi-field-mapping/14652 "2013-12-01T14:04:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_de\_Vries](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james_de_vries/32/1946_2.png) [@James\_de\_Vries](https://discuss.elastic.co/u/James_de_Vries)\
**Post date:** [December 1, 2013, 2:04pm UTC](https://discuss.elastic.co/t/multi-field-mapping/14652/1 "2013-12-01T14:04:16Z")

</div>

I have been experimenting with attempting to make a single field searchable  
when analyzed, and when not analyzed. According to the docs, the multi  
field type[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-multi-field-type.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-multi-field-type.html)is the tool for the job. In place of the old mapping for that field, which  
was simply:  
{"myfieldname" : { "type":"string"}}  
I have set it to be the following, through the put mapping API:  
{  
"mytype" : {  
"properties" : {  
"myfieldname" : {  
"type" : "multi\_field",  
"fields" : {  
"myfieldname" : {"type" : "string", "index" :  
"not\_analyzed"},  
"myfieldname\_special" : {  
"type" : "string",  
"index" : "analyzed",  
"analyzer":"phonetic",  
}  
}  
}  
}  
}  
}

It is my understanding that "analyzer" sets both search\_analyzer and  
index\_analyzer, so I did curl -XPOST  
'[http://localhost:9200/myindex/\_refresh](http://localhost:9200/myindex/_refresh)' to rebuild the index. However any  
query over myfieldname\_special returns zero results ☹  
I am not sure what it is that i've missed. Could anybody help me 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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e3155fab-5702-4076-9c82-63c681e108a8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e3155fab-5702-4076-9c82-63c681e108a8%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [December 2, 2013, 9:48am UTC](https://discuss.elastic.co/t/multi-field-mapping/14652/2 "2013-12-02T09:48:15Z")

</div>

Hi James,

I think that by default you have to refer to that field as  
"myfieldname.myfieldname\_special", while the other one can simply be  
"myfieldname", since it's the "default" name. You can set the "path" option  
to "just\_name" to be able to refer it via myfieldname\_special.

Best regards,  
Radu

On Sun, Dec 1, 2013 at 4:04 PM, James de Vries [shadylives@gmail.com](mailto:shadylives@gmail.com) wrote:

> I have been experimenting with attempting to make a single field  
> searchable when analyzed, and when not analyzed. According to the docs, the multi  
> field type[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-multi-field-type.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-multi-field-type.html)is the tool for the job. In place of the old mapping for that field, which  
> was simply:  
> {"myfieldname" : { "type":"string"}}  
> I have set it to be the following, through the put mapping API:  
> {  
> "mytype" : {  
> "properties" : {  
> "myfieldname" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "myfieldname" : {"type" : "string", "index" :  
> "not\_analyzed"},  
> "myfieldname\_special" : {  
> "type" : "string",  
> "index" : "analyzed",  
> "analyzer":"phonetic",  
> }  
> }  
> }  
> }  
> }  
> }
> 
> It is my understanding that "analyzer" sets both search\_analyzer and  
> index\_analyzer, so I did curl -XPOST '  
> [http://localhost:9200/myindex/\_refresh](http://localhost:9200/myindex/_refresh)' to rebuild the index. However any  
> query over myfieldname\_special returns zero results ☹  
> I am not sure what it is that i've missed. Could anybody help me 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e3155fab-5702-4076-9c82-63c681e108a8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e3155fab-5702-4076-9c82-63c681e108a8%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Performance Monitoring \* Log Analytics \* Search Analytics  
Solr & Elasticsearch Support \* [http://sematext.com/](http://sematext.com/)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHXA0\_2sX6xRARQRm3HqRVJz%2BgjP5-T2oKMgTQY5kTs31Nwt%3DA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHXA0_2sX6xRARQRm3HqRVJz%2BgjP5-T2oKMgTQY5kTs31Nwt%3DA%40mail.gmail.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:03am UTC](https://discuss.elastic.co/t/multi-field-mapping/14652/3 "2017-07-06T02:03:56Z")

</div>


