# Searching on multi-field fields

**URL:** <https://discuss.elastic.co/t/searching-on-multi-field-fields/5618>\
**Category:** Elasticsearch\
**Created:** [October 17, 2011, 7:55pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618 "2011-10-17T19:55:29Z")\
**Posts on this page:** 9\
**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 17, 2011, 7:55pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/1 "2011-10-17T19:55:29Z")

</div>

Hi,

I have an index with a multi-field field using the example in  
[http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)

{  
"tweet" : {  
"properties" : {  
"name" : {  
"type" : "multi\_field",  
"fields" : {  
"name" : {"type" : "string", "index" :  
"analyzed"},  
"untouched" : {"type" : "string", "index" :  
"not\_analyzed"}  
}  
}  
}  
}  
}

However, I can't seem to successful query nor perform faceting on the  
multi-field.

EG: [http://localhost:9200/twitter/tweet/\_search?q=name.untouched:\*](http://localhost:9200/twitter/tweet/_search?q=name.untouched:*)  
(using 'name.untouched' as recommended in  
[http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html))  
returns no results.

Is my syntax incorrect, or does multi-field fields not support  
querying (but that would not make sense)?

---

<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 17, 2011, 8:49pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/2 "2011-10-17T20:49:46Z")

</div>

To provide more detail:

[http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=)\*  
works in that all docs are retrieved with only the name.untouched  
field, but [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=name.untouched:](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=name.untouched:)\*  
does not work.

Is this a bug?

On Oct 17, 3:55 pm, datadev [n...@adinfocenter.com](mailto:n...@adinfocenter.com) wrote:

> Hi,
> 
> I have an index with a multi-field field using the example inhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type...
> 
> {  
> "tweet" : {  
> "properties" : {  
> "name" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "name" : {"type" : "string", "index" :  
> "analyzed"},  
> "untouched" : {"type" : "string", "index" :  
> "not\_analyzed"}  
> }  
> }  
> }  
> }
> 
> }
> 
> However, I can't seem to successful query nor perform faceting on the  
> multi-field.
> 
> EG:[http://localhost:9200/twitter/tweet/\_search?q=name.untouched:](http://localhost:9200/twitter/tweet/_search?q=name.untouched:)\*  
> (using 'name.untouched' as recommended inhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type...)  
> returns no results.
> 
> Is my syntax incorrect, or does multi-field fields not support  
> querying (but that would not make sense)?

---

<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, 12:08am UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/3 "2011-10-18T00:08:50Z")

</div>

You can't ask for name.untouched to be returned as its not stored, and not  
part of the json to be extracted from. When you ask for a field to be  
returned, it either needs to be stored, or, it needs to be a valid path  
"into" the source json document.

On Mon, Oct 17, 2011 at 10:49 PM, datadev [nji@adinfocenter.com](mailto:nji@adinfocenter.com) wrote:

> To provide more detail:
> 
> [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=)\*  
> works in that all docs are retrieved with only the name.untouched  
> field, but  
> [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=name.untouched:](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=name.untouched:)\*  
> does not work.
> 
> Is this a bug?
> 
> On Oct 17, 3:55 pm, datadev [n...@adinfocenter.com](mailto:n...@adinfocenter.com) wrote:
> 
> > Hi,
> > 
> > I have an index with a multi-field field using the example inhttp://  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type)...
> > 
> > {  
> > "tweet" : {  
> > "properties" : {  
> > "name" : {  
> > "type" : "multi\_field",  
> > "fields" : {  
> > "name" : {"type" : "string", "index" :  
> > "analyzed"},  
> > "untouched" : {"type" : "string", "index" :  
> > "not\_analyzed"}  
> > }  
> > }  
> > }  
> > }
> > 
> > }
> > 
> > However, I can't seem to successful query nor perform faceting on the  
> > multi-field.
> > 
> > EG:[http://localhost:9200/twitter/tweet/\_search?q=name.untouched:](http://localhost:9200/twitter/tweet/_search?q=name.untouched:)\*  
> > (using 'name.untouched' as recommended inhttp://  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type)...)  
> > returns no results.
> > 
> > Is my syntax incorrect, or does multi-field fields not support  
> > querying (but that would not make sense)?

---

<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, 12:39am UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/4 "2011-10-18T00:39:56Z")

</div>

Hi Shay,

The name.untouched is stored. When I do q=\*, the name.untouched values  
do show up in the result set, and I can also limit the returned field  
values to only name.untouched via fields=name.untouched.

The problem is that I get an empty result set when I do  
q=name.untouched:\*

Do I have the incorrect query syntax or maybe this is a bug?

On Oct 17, 8:08 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You can't ask for name.untouched to be returned as its not stored, and not  
> part of the json to be extracted from. When you ask for a field to be  
> returned, it either needs to be stored, or, it needs to be a valid path  
> "into" the source json document.
> 
> On Mon, Oct 17, 2011 at 10:49 PM, datadev [n...@adinfocenter.com](mailto:n...@adinfocenter.com) wrote:
> 
> > To provide more detail:
> 
> > [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=)\*  
> > works in that all docs are retrieved with only the name.untouched  
> > field, but  
> > [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=n](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=n)...  
> > does not work.
> 
> > Is this a bug?
> 
> > On Oct 17, 3:55 pm, datadev [n...@adinfocenter.com](mailto:n...@adinfocenter.com) wrote:
> > 
> > > Hi,
> 
> > > I have an index with a multi-field field using the example inhttp://  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type)...
> 
> > > {  
> > > "tweet" : {  
> > > "properties" : {  
> > > "name" : {  
> > > "type" : "multi\_field",  
> > > "fields" : {  
> > > "name" : {"type" : "string", "index" :  
> > > "analyzed"},  
> > > "untouched" : {"type" : "string", "index" :  
> > > "not\_analyzed"}  
> > > }  
> > > }  
> > > }  
> > > }
> 
> > > }
> 
> > > However, I can't seem to successful query nor perform faceting on the  
> > > multi-field.
> 
> > > EG:[http://localhost:9200/twitter/tweet/\_search?q=name.untouched:](http://localhost:9200/twitter/tweet/_search?q=name.untouched:)\*  
> > > (using 'name.untouched' as recommended inhttp://  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type)...)  
> > > returns no results.
> 
> > > Is my syntax incorrect, or does multi-field fields not support  
> > > querying (but that would not make sense)?

---

<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:29pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/5 "2011-10-18T17:29:22Z")

</div>

Heya, this seems to work: [gist:1296043 · GitHub](https://gist.github.com/1296043). Maybe you can  
change it to show the problem you are having?

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

> Hi Shay,
> 
> The name.untouched is stored. When I do q=\*, the name.untouched values  
> do show up in the result set, and I can also limit the returned field  
> values to only name.untouched via fields=name.untouched.
> 
> The problem is that I get an empty result set when I do  
> q=name.untouched:\*
> 
> Do I have the incorrect query syntax or maybe this is a bug?
> 
> On Oct 17, 8:08 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > You can't ask for name.untouched to be returned as its not stored, and  
> > not  
> > part of the json to be extracted from. When you ask for a field to be  
> > returned, it either needs to be stored, or, it needs to be a valid path  
> > "into" the source json document.
> > 
> > On Mon, Oct 17, 2011 at 10:49 PM, datadev [n...@adinfocenter.com](mailto:n...@adinfocenter.com) wrote:
> > 
> > > To provide more detail:
> > 
> > > [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=)\*  
> > > works in that all docs are retrieved with only the name.untouched  
> > > field, but  
> > > [http://localhost:9200/twitter/tweet/\_search?fields=name.untouched&q=n](http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=n).  
> > > ..  
> > > does not work.
> > 
> > > Is this a bug?
> > 
> > > On Oct 17, 3:55 pm, datadev [n...@adinfocenter.com](mailto:n...@adinfocenter.com) wrote:
> > > 
> > > > Hi,
> > 
> > > > I have an index with a multi-field field using the example inhttp://  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type)...
> > 
> > > > {  
> > > > "tweet" : {  
> > > > "properties" : {  
> > > > "name" : {  
> > > > "type" : "multi\_field",  
> > > > "fields" : {  
> > > > "name" : {"type" : "string", "index" :  
> > > > "analyzed"},  
> > > > "untouched" : {"type" : "string", "index" :  
> > > > "not\_analyzed"}  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > 
> > > > }
> > 
> > > > However, I can't seem to successful query nor perform faceting on the  
> > > > multi-field.
> > 
> > > > EG:[http://localhost:9200/twitter/tweet/\_search?q=name.untouched:](http://localhost:9200/twitter/tweet/_search?q=name.untouched:)\*  
> > > > (using 'name.untouched' as recommended inhttp://  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type)...)  
> > > > returns no results.
> > 
> > > > Is my syntax incorrect, or does multi-field fields not support  
> > > > querying (but that would not make sense)?

---

<div class="post-metadata">

**Author:** ![rlong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rlong/32/3101_2.png) [@rlong](https://discuss.elastic.co/u/rlong)\
**Post date:** [October 20, 2011, 6:20pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/6 "2011-10-20T18:20:09Z")

</div>

I am also experiencing this same behavior. None of the multi-fields are coming back in a query result. I can view the values in a q=_:_ but if I do a q=parent.child:\* it doesn't return anything. This is the exact same behavior explained above in this article. Even when I copy the code at [https://gist.github.com/1296043](https://gist.github.com/1296043) verbatim, I am still not able to get back any results.

Is there some type of configuration that has to be done?

Thanks!

rlong

---

<div class="post-metadata">

**Author:** ![rlong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rlong/32/3101_2.png) [@rlong](https://discuss.elastic.co/u/rlong)\
**Post date:** [October 20, 2011, 7:53pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/7 "2011-10-20T19:53:48Z")

</div>

Here is the test scenario I am trying to conduct:

curl -XPUT localhost:9200/6 -d '{  
"mappings" : {  
"type1" : {  
"properties" : {  
"name" : {  
"type" : "multi\_field",  
"fields" : {  
"name" : {"type" : "string", "index" : "analyzed"},  
"untouched" : {"type" : "string", "index" : "not\_analyzed"}  
}  
}  
}  
}  
}  
}'

curl -XPUT localhost:9200/6/type1/1 -d '{  
"name" : {"name":"test me","untouched":"test1"}  
}'

curl -XPUT localhost:9200/6/type1/2 -d '{  
"name" : {"name":"test me","untouched":"test2"}  
}'

curl -XPUT localhost:9200/6/type1/3 -d '{  
"name" : {"name":"test me","untouched":"test3"}  
}'

curl -XPOST localhost:9200/6/\_refresh

This returns all 3 documents:

curl -XPUT localhost:9200/6/type1/\_search?q=name.untouched:\*

This returns nothing:

curl -XPUT localhost:9200/6/type1/\_search?q=name.untouched:test3

---

<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 21, 2011, 6:33pm UTC](https://discuss.elastic.co/t/searching-on-multi-field-fields/5618/8 "2011-10-21T18:33:57Z")

</div>

I think you misunderstood what multi field is for. The idea of multi field  
is that for the _same_ json field value (in your case, name), it will be  
indexed in two different manners, one under "name", and one under  
"name.untouched". In your case, you have two \*different" json fields,  
"name", and "untouched", with _different_ values. So you should simply have  
two different mappings for those.

On Thu, Oct 20, 2011 at 9:53 PM, rlong [rlliii@hotmail.com](mailto:rlliii@hotmail.com) wrote:

> Here is the test scenario I am trying to conduct:
> 
> curl -XPUT localhost:9200/6 -d '{  
> "mappings" : {  
> "type1" : {  
> "properties" : {  
> "name" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "name" : {"type" : "string", "index" : "analyzed"},  
> "untouched" : {"type" : "string", "index" : "not\_analyzed"}  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> curl -XPUT localhost:9200/6/type1/1 -d '{  
> "name" : {"name":"test me","untouched":"test1"}  
> }'
> 
> curl -XPUT localhost:9200/6/type1/2 -d '{  
> "name" : {"name":"test me","untouched":"test2"}  
> }'
> 
> curl -XPUT localhost:9200/6/type1/3 -d '{  
> "name" : {"name":"test me","untouched":"test3"}  
> }'
> 
> curl -XPOST localhost:9200/6/\_refresh
> 
> This returns all 3 documents:
> 
> curl -XPUT localhost:9200/6/type1/\_search?q=name.untouched:\*
> 
> This returns nothing:
> 
> curl -XPUT localhost:9200/6/type1/\_search?q=name.untouched:test3
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Searching-on-multi-field-fields-tp3429284p3438812.html](http://elasticsearch-users.115913.n3.nabble.com/Searching-on-multi-field-fields-tp3429284p3438812.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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/searching-on-multi-field-fields/5618/9 "2017-07-06T03:51:11Z")

</div>


