# Question about multi\_field and edge ngram

**URL:** <https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885>\
**Category:** Elasticsearch\
**Created:** [March 5, 2012, 7:07am UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885 "2012-03-05T07:07:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![quain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quain/32/2925_2.png) [@quain](https://discuss.elastic.co/u/quain)\
**Post date:** [March 5, 2012, 7:07am UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/1 "2012-03-05T07:07:04Z")

</div>

I'm having some trouble with multi\_field, perhaps some of you guys  
could shed some light on what I'm doing wrong. After I inserted some  
documents, I get 0 hits for any searches of the field name.untouched  
or name.ngram. I am successful with the main field just searching on  
name. For example, the following returns nothing even though i know  
the term is there exactly:

curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
{  
"query" : {  
"text" : {  
"name.ngram" : {  
"query" : "xyz"  
}  
}  
}  
}  
'

Here's my mapping:

curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
{  
"mappings" : {  
"member" : {  
"properties" : {  
"name" : {  
"type": "multi\_field",  
"fields" : {  
"untouched": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"name": {  
"type": "string",  
"analyzer": "standard\_name"  
},  
"ngram" : {  
"search\_analyzer": "standard\_name",  
"index\_analyzer": "partial\_name",  
"type": "string"  
}  
}  
}  
}  
}  
},  
"settings" : {  
"analysis" : {  
"filter" : {  
"name\_ngrams" : {  
"side" : "front",  
"max\_gram" : 10,  
"min\_gram" : 1,  
"type" : "edgeNGram"  
}  
},  
"analyzer" : {  
"standard\_name" : {  
"filter" : [  
"standard",  
"lowercase",  
"asciifolding"  
],  
"type" : "custom",  
"tokenizer" : "standard"  
},  
"partial\_name" : {  
"filter" : [  
"standard",  
"lowercase",  
"asciifolding",  
"name\_ngrams"  
],  
"type" : "custom",  
"tokenizer" : "standard"  
}  
}  
}  
}  
}  
'

Can anyone give me some help to identify what might be wrong?

---

<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:** [March 5, 2012, 3:19pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/2 "2012-03-05T15:19:07Z")

</div>

Can you gist a sample with setting up the index, the mappings, indexing sample doc(s) and then showing the search request that do not work for you? It would help a lot. (see [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)).

On Monday, March 5, 2012 at 9:07 AM, quain wrote:

> I'm having some trouble with multi\_field, perhaps some of you guys  
> could shed some light on what I'm doing wrong. After I inserted some  
> documents, I get 0 hits for any searches of the field name.untouched  
> or name.ngram. I am successful with the main field just searching on  
> name. For example, the following returns nothing even though i know  
> the term is there exactly:
> 
> curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "text" : {  
> "name.ngram" : {  
> "query" : "xyz"  
> }  
> }  
> }  
> }  
> '
> 
> Here's my mapping:
> 
> curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> {  
> "mappings" : {  
> "member" : {  
> "properties" : {  
> "name" : {  
> "type": "multi\_field",  
> "fields" : {  
> "untouched": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> "name": {  
> "type": "string",  
> "analyzer": "standard\_name"  
> },  
> "ngram" : {  
> "search\_analyzer": "standard\_name",  
> "index\_analyzer": "partial\_name",  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> },  
> "settings" : {  
> "analysis" : {  
> "filter" : {  
> "name\_ngrams" : {  
> "side" : "front",  
> "max\_gram" : 10,  
> "min\_gram" : 1,  
> "type" : "edgeNGram"  
> }  
> },  
> "analyzer" : {  
> "standard\_name" : {  
> "filter" : [  
> "standard",  
> "lowercase",  
> "asciifolding"  
> ],  
> "type" : "custom",  
> "tokenizer" : "standard"  
> },  
> "partial\_name" : {  
> "filter" : [  
> "standard",  
> "lowercase",  
> "asciifolding",  
> "name\_ngrams"  
> ],  
> "type" : "custom",  
> "tokenizer" : "standard"  
> }  
> }  
> }  
> }  
> }  
> '
> 
> Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![quain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quain/32/2925_2.png) [@quain](https://discuss.elastic.co/u/quain)\
**Post date:** [March 5, 2012, 4:31pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/3 "2012-03-05T16:31:38Z")

</div>

> <https://gist.github.com/jwyuan/1979125>

Here is the gist. Thanks very much for any help that can be  
provided. I'm mostly interested in if I'm setting up the mapping  
incorrectly, or using the multi\_field or ngram types incorrectly.

On Mar 5, 7:19 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Can you gist a sample with setting up the index, the mappings, indexing sample doc(s) and then showing the search request that do not work for you? It would help a lot. (seehttp://www.elasticsearch.org/help).
> 
> On Monday, March 5, 2012 at 9:07 AM, quain wrote:
> 
> > I'm having some trouble with multi\_field, perhaps some of you guys  
> > could shed some light on what I'm doing wrong. After I inserted some  
> > documents, I get 0 hits for any searches of the field name.untouched  
> > or name.ngram. I am successful with the main field just searching on  
> > name. For example, the following returns nothing even though i know  
> > the term is there exactly:
> 
> > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > {  
> > "query" : {  
> > "text" : {  
> > "name.ngram" : {  
> > "query" : "xyz"  
> > }  
> > }  
> > }  
> > }  
> > '
> 
> > Here's my mapping:
> 
> > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > {  
> > "mappings" : {  
> > "member" : {  
> > "properties" : {  
> > "name" : {  
> > "type": "multi\_field",  
> > "fields" : {  
> > "untouched": {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > },  
> > "name": {  
> > "type": "string",  
> > "analyzer": "standard\_name"  
> > },  
> > "ngram" : {  
> > "search\_analyzer": "standard\_name",  
> > "index\_analyzer": "partial\_name",  
> > "type": "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "settings" : {  
> > "analysis" : {  
> > "filter" : {  
> > "name\_ngrams" : {  
> > "side" : "front",  
> > "max\_gram" : 10,  
> > "min\_gram" : 1,  
> > "type" : "edgeNGram"  
> > }  
> > },  
> > "analyzer" : {  
> > "standard\_name" : {  
> > "filter" : [  
> > "standard",  
> > "lowercase",  
> > "asciifolding"  
> > ],  
> > "type" : "custom",  
> > "tokenizer" : "standard"  
> > },  
> > "partial\_name" : {  
> > "filter" : [  
> > "standard",  
> > "lowercase",  
> > "asciifolding",  
> > "name\_ngrams"  
> > ],  
> > "type" : "custom",  
> > "tokenizer" : "standard"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > '
> 
> > Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![Garrick\_Evans](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@Garrick\_Evans](https://discuss.elastic.co/u/Garrick_Evans)\
**Post date:** [March 5, 2012, 6:35pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/4 "2012-03-05T18:35:47Z")

</div>

What if you

"query":{"text":{"name.ngram":"xyz"}}}

?

On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:

> I'm having some trouble with multi\_field, perhaps some of you guys  
> could shed some light on what I'm doing wrong. After I inserted some  
> documents, I get 0 hits for any searches of the field name.untouched  
> or name.ngram. I am successful with the main field just searching on  
> name. For example, the following returns nothing even though i know  
> the term is there exactly:
> 
> curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "text" : {  
> "name.ngram" : {  
> "query" : "xyz"  
> }  
> }  
> }  
> }  
> '
> 
> Here's my mapping:
> 
> curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> {  
> "mappings" : {  
> "member" : {  
> "properties" : {  
> "name" : {  
> "type": "multi\_field",  
> "fields" : {  
> "untouched": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> "name": {  
> "type": "string",  
> "analyzer": "standard\_name"  
> },  
> "ngram" : {  
> "search\_analyzer": "standard\_name",  
> "index\_analyzer": "partial\_name",  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> },  
> "settings" : {  
> "analysis" : {  
> "filter" : {  
> "name\_ngrams" : {  
> "side" : "front",  
> "max\_gram" : 10,  
> "min\_gram" : 1,  
> "type" : "edgeNGram"  
> }  
> },  
> "analyzer" : {  
> "standard\_name" : {  
> "filter" : [  
> "standard",  
> "lowercase",  
> "asciifolding"  
> ],  
> "type" : "custom",  
> "tokenizer" : "standard"  
> },  
> "partial\_name" : {  
> "filter" : [  
> "standard",  
> "lowercase",  
> "asciifolding",  
> "name\_ngrams"  
> ],  
> "type" : "custom",  
> "tokenizer" : "standard"  
> }  
> }  
> }  
> }  
> }  
> '
> 
> Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![quain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quain/32/2925_2.png) [@quain](https://discuss.elastic.co/u/quain)\
**Post date:** [March 5, 2012, 7:10pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/5 "2012-03-05T19:10:51Z")

</div>

Thanks, but I got the same result, still 0 hits. I didn't get a  
syntax error the first time either, so not sure this is the problem.

I thought I pretty much followed the documentation on this, not sure  
why it doesn't work.

On Mar 5, 10:35 am, Garrick Evans [buk...@gmail.com](mailto:buk...@gmail.com) wrote:

> What if you
> 
> "query":{"text":{"name.ngram":"xyz"}}}
> 
> ?
> 
> On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> 
> > I'm having some trouble with multi\_field, perhaps some of you guys  
> > could shed some light on what I'm doing wrong. After I inserted some  
> > documents, I get 0 hits for any searches of the field name.untouched  
> > or name.ngram. I am successful with the main field just searching on  
> > name. For example, the following returns nothing even though i know  
> > the term is there exactly:
> 
> > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> > {  
> > "query" : {  
> > "text" : {  
> > "name.ngram" : {  
> > "query" : "xyz"  
> > }  
> > }  
> > }  
> > }  
> > '
> 
> > Here's my mapping:
> 
> > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> > {  
> > "mappings" : {  
> > "member" : {  
> > "properties" : {  
> > "name" : {  
> > "type": "multi\_field",  
> > "fields" : {  
> > "untouched": {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > },  
> > "name": {  
> > "type": "string",  
> > "analyzer": "standard\_name"  
> > },  
> > "ngram" : {  
> > "search\_analyzer": "standard\_name",  
> > "index\_analyzer": "partial\_name",  
> > "type": "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "settings" : {  
> > "analysis" : {  
> > "filter" : {  
> > "name\_ngrams" : {  
> > "side" : "front",  
> > "max\_gram" : 10,  
> > "min\_gram" : 1,  
> > "type" : "edgeNGram"  
> > }  
> > },  
> > "analyzer" : {  
> > "standard\_name" : {  
> > "filter" : [  
> > "standard",  
> > "lowercase",  
> > "asciifolding"  
> > ],  
> > "type" : "custom",  
> > "tokenizer" : "standard"  
> > },  
> > "partial\_name" : {  
> > "filter" : [  
> > "standard",  
> > "lowercase",  
> > "asciifolding",  
> > "name\_ngrams"  
> > ],  
> > "type" : "custom",  
> > "tokenizer" : "standard"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > '
> 
> > Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![Garrick\_Evans](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@Garrick\_Evans](https://discuss.elastic.co/u/Garrick_Evans)\
**Post date:** [March 5, 2012, 8:33pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/6 "2012-03-05T20:33:59Z")

</div>

You are posting to a "test" type but you created the mapping for "member".  
Try:

> curl - POST '[http://localhost:9200/test/member?pretty=true](http://localhost:9200/test/member?pretty=true)' -d '{ "name" :  
> "The Office" }'  
> curl - POST '[http://localhost:9200/test/member?pretty=true](http://localhost:9200/test/member?pretty=true)' -d '{ "name" :  
> "The Office (UK)" }'

You should then be able to query like:

> curl -XGET [http://localhost:9200/test/\_search?pretty=1](http://localhost:9200/test/_search?pretty=1) -d  
> '{"query":{"text":{"name.ngram":"th"}}}'  
> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 2,  
> "max\_score" : 0.25,  
> "hits" : [ {  
> "\_index" : "test",  
> "\_type" : "member",  
> "\_id" : "MLleoK0pR8eBGhY9pkm0ig",  
> "\_score" : 0.25, "\_source" : { "name" : "The Office (UK)" }  
> }, {  
> "\_index" : "test",  
> "\_type" : "member",  
> "\_id" : "nzY1KZ6mRuqrzxosJBi9IQ",  
> "\_score" : 0.095891505, "\_source" : { "name" : "The Office" }  
> } ]  
> }

On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:

> Thanks, but I got the same result, still 0 hits. I didn't get a  
> syntax error the first time either, so not sure this is the problem.
> 
> I thought I pretty much followed the documentation on this, not sure  
> why it doesn't work.
> 
> On Mar 5, 10:35 am, Garrick Evans [buk...@gmail.com](mailto:buk...@gmail.com) wrote:
> 
> > What if you
> > 
> > "query":{"text":{"name.ngram":"xyz"}}}
> > 
> > ?
> > 
> > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> > 
> > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > could shed some light on what I'm doing wrong. After I inserted some  
> > > documents, I get 0 hits for any searches of the field name.untouched  
> > > or name.ngram. I am successful with the main field just searching on  
> > > name. For example, the following returns nothing even though i know  
> > > the term is there exactly:
> > 
> > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> > > {  
> > > "query" : {  
> > > "text" : {  
> > > "name.ngram" : {  
> > > "query" : "xyz"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > '
> > 
> > > Here's my mapping:
> > 
> > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> > > {  
> > > "mappings" : {  
> > > "member" : {  
> > > "properties" : {  
> > > "name" : {  
> > > "type": "multi\_field",  
> > > "fields" : {  
> > > "untouched": {  
> > > "type": "string",  
> > > "index": "not\_analyzed"  
> > > },  
> > > "name": {  
> > > "type": "string",  
> > > "analyzer": "standard\_name"  
> > > },  
> > > "ngram" : {  
> > > "search\_analyzer": "standard\_name",  
> > > "index\_analyzer": "partial\_name",  
> > > "type": "string"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > },  
> > > "settings" : {  
> > > "analysis" : {  
> > > "filter" : {  
> > > "name\_ngrams" : {  
> > > "side" : "front",  
> > > "max\_gram" : 10,  
> > > "min\_gram" : 1,  
> > > "type" : "edgeNGram"  
> > > }  
> > > },  
> > > "analyzer" : {  
> > > "standard\_name" : {  
> > > "filter" : [  
> > > "standard",  
> > > "lowercase",  
> > > "asciifolding"  
> > > ],  
> > > "type" : "custom",  
> > > "tokenizer" : "standard"  
> > > },  
> > > "partial\_name" : {  
> > > "filter" : [  
> > > "standard",  
> > > "lowercase",  
> > > "asciifolding",  
> > > "name\_ngrams"  
> > > ],  
> > > "type" : "custom",  
> > > "tokenizer" : "standard"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > '
> > 
> > > Can anyone give me some help to identify what might be wrong?

On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:

> Thanks, but I got the same result, still 0 hits. I didn't get a  
> syntax error the first time either, so not sure this is the problem.
> 
> I thought I pretty much followed the documentation on this, not sure  
> why it doesn't work.
> 
> On Mar 5, 10:35 am, Garrick Evans [buk...@gmail.com](mailto:buk...@gmail.com) wrote:
> 
> > What if you
> > 
> > "query":{"text":{"name.ngram":"xyz"}}}
> > 
> > ?
> > 
> > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> > 
> > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > could shed some light on what I'm doing wrong. After I inserted some  
> > > documents, I get 0 hits for any searches of the field name.untouched  
> > > or name.ngram. I am successful with the main field just searching on  
> > > name. For example, the following returns nothing even though i know  
> > > the term is there exactly:
> > 
> > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> > > {  
> > > "query" : {  
> > > "text" : {  
> > > "name.ngram" : {  
> > > "query" : "xyz"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > '
> > 
> > > Here's my mapping:
> > 
> > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> > > {  
> > > "mappings" : {  
> > > "member" : {  
> > > "properties" : {  
> > > "name" : {  
> > > "type": "multi\_field",  
> > > "fields" : {  
> > > "untouched": {  
> > > "type": "string",  
> > > "index": "not\_analyzed"  
> > > },  
> > > "name": {  
> > > "type": "string",  
> > > "analyzer": "standard\_name"  
> > > },  
> > > "ngram" : {  
> > > "search\_analyzer": "standard\_name",  
> > > "index\_analyzer": "partial\_name",  
> > > "type": "string"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > },  
> > > "settings" : {  
> > > "analysis" : {  
> > > "filter" : {  
> > > "name\_ngrams" : {  
> > > "side" : "front",  
> > > "max\_gram" : 10,  
> > > "min\_gram" : 1,  
> > > "type" : "edgeNGram"  
> > > }  
> > > },  
> > > "analyzer" : {  
> > > "standard\_name" : {  
> > > "filter" : [  
> > > "standard",  
> > > "lowercase",  
> > > "asciifolding"  
> > > ],  
> > > "type" : "custom",  
> > > "tokenizer" : "standard"  
> > > },  
> > > "partial\_name" : {  
> > > "filter" : [  
> > > "standard",  
> > > "lowercase",  
> > > "asciifolding",  
> > > "name\_ngrams"  
> > > ],  
> > > "type" : "custom",  
> > > "tokenizer" : "standard"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > '
> > 
> > > Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![quain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quain/32/2925_2.png) [@quain](https://discuss.elastic.co/u/quain)\
**Post date:** [March 5, 2012, 11:35pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/7 "2012-03-05T23:35:31Z")

</div>

Thanks a lot for pointing this out. This was the problem.

I was wondering, is it possible to apply this mapping to all types  
within an index? For example, if I wanted to set the mapping for the  
"name" field for all types of the index "test", can I do that?

On Mar 5, 12:33 pm, Garrick Evans [buk...@gmail.com](mailto:buk...@gmail.com) wrote:

> You are posting to a "test" type but you created the mapping for "member".  
> Try:
> 
> > curl - POST '[http://localhost:9200/test/member?pretty=true'-d](http://localhost:9200/test/member?pretty=true'-d) '{ "name" :  
> > "The Office" }'  
> > curl - POST '[http://localhost:9200/test/member?pretty=true'-d](http://localhost:9200/test/member?pretty=true'-d) '{ "name" :  
> > "The Office (UK)" }'
> 
> You should then be able to query like:
> 
> > curl -XGEThttp://localhost:9200/test/\_search?pretty=1-d  
> > '{"query":{"text":{"name.ngram":"th"}}}'  
> > {  
> > "took" : 1,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 2,  
> > "max\_score" : 0.25,  
> > "hits" : [ {  
> > "\_index" : "test",  
> > "\_type" : "member",  
> > "\_id" : "MLleoK0pR8eBGhY9pkm0ig",  
> > "\_score" : 0.25, "\_source" : { "name" : "The Office (UK)" }  
> > }, {  
> > "\_index" : "test",  
> > "\_type" : "member",  
> > "\_id" : "nzY1KZ6mRuqrzxosJBi9IQ",  
> > "\_score" : 0.095891505, "\_source" : { "name" : "The Office" }  
> > } ]  
> > }  
> > On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:
> 
> > Thanks, but I got the same result, still 0 hits. I didn't get a  
> > syntax error the first time either, so not sure this is the problem.
> 
> > I thought I pretty much followed the documentation on this, not sure  
> > why it doesn't work.
> 
> > On Mar 5, 10:35 am, Garrick Evans [buk...@gmail.com](mailto:buk...@gmail.com) wrote:
> > 
> > > What if you
> 
> > > "query":{"text":{"name.ngram":"xyz"}}}
> 
> > > ?
> 
> > > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> 
> > > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > > could shed some light on what I'm doing wrong. After I inserted some  
> > > > documents, I get 0 hits for any searches of the field name.untouched  
> > > > or name.ngram. I am successful with the main field just searching on  
> > > > name. For example, the following returns nothing even though i know  
> > > > the term is there exactly:
> 
> > > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > > > {  
> > > > "query" : {  
> > > > "text" : {  
> > > > "name.ngram" : {  
> > > > "query" : "xyz"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > '
> 
> > > > Here's my mapping:
> 
> > > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > > > {  
> > > > "mappings" : {  
> > > > "member" : {  
> > > > "properties" : {  
> > > > "name" : {  
> > > > "type": "multi\_field",  
> > > > "fields" : {  
> > > > "untouched": {  
> > > > "type": "string",  
> > > > "index": "not\_analyzed"  
> > > > },  
> > > > "name": {  
> > > > "type": "string",  
> > > > "analyzer": "standard\_name"  
> > > > },  
> > > > "ngram" : {  
> > > > "search\_analyzer": "standard\_name",  
> > > > "index\_analyzer": "partial\_name",  
> > > > "type": "string"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > },  
> > > > "settings" : {  
> > > > "analysis" : {  
> > > > "filter" : {  
> > > > "name\_ngrams" : {  
> > > > "side" : "front",  
> > > > "max\_gram" : 10,  
> > > > "min\_gram" : 1,  
> > > > "type" : "edgeNGram"  
> > > > }  
> > > > },  
> > > > "analyzer" : {  
> > > > "standard\_name" : {  
> > > > "filter" : [  
> > > > "standard",  
> > > > "lowercase",  
> > > > "asciifolding"  
> > > > ],  
> > > > "type" : "custom",  
> > > > "tokenizer" : "standard"  
> > > > },  
> > > > "partial\_name" : {  
> > > > "filter" : [  
> > > > "standard",  
> > > > "lowercase",  
> > > > "asciifolding",  
> > > > "name\_ngrams"  
> > > > ],  
> > > > "type" : "custom",  
> > > > "tokenizer" : "standard"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > '
> 
> > > > Can anyone give me some help to identify what might be wrong?  
> > > > On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:
> 
> > Thanks, but I got the same result, still 0 hits. I didn't get a  
> > syntax error the first time either, so not sure this is the problem.
> 
> > I thought I pretty much followed the documentation on this, not sure  
> > why it doesn't work.
> 
> > On Mar 5, 10:35 am, Garrick Evans [buk...@gmail.com](mailto:buk...@gmail.com) wrote:
> > 
> > > What if you
> 
> > > "query":{"text":{"name.ngram":"xyz"}}}
> 
> > > ?
> 
> > > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> 
> > > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > > could shed some light on what I'm doing wrong. After I inserted some  
> > > > documents, I get 0 hits for any searches of the field name.untouched  
> > > > or name.ngram. I am successful with the main field just searching on  
> > > > name. For example, the following returns nothing even though i know  
> > > > the term is there exactly:
> 
> > > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > > > {  
> > > > "query" : {  
> > > > "text" : {  
> > > > "name.ngram" : {  
> > > > "query" : "xyz"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > '
> 
> > > > Here's my mapping:
> 
> > > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > > > {  
> > > > "mappings" : {  
> > > > "member" : {  
> > > > "properties" : {  
> > > > "name" : {  
> > > > "type": "multi\_field",  
> > > > "fields" : {  
> > > > "untouched": {  
> > > > "type": "string",  
> > > > "index": "not\_analyzed"  
> > > > },  
> > > > "name": {  
> > > > "type": "string",  
> > > > "analyzer": "standard\_name"  
> > > > },  
> > > > "ngram" : {  
> > > > "search\_analyzer": "standard\_name",  
> > > > "index\_analyzer": "partial\_name",  
> > > > "type": "string"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > },  
> > > > "settings" : {  
> > > > "analysis" : {  
> > > > "filter" : {  
> > > > "name\_ngrams" : {  
> > > > "side" : "front",  
> > > > "max\_gram" : 10,  
> > > > "min\_gram" : 1,  
> > > > "type" : "edgeNGram"  
> > > > }  
> > > > },  
> > > > "analyzer" : {  
> > > > "standard\_name" : {  
> > > > "filter" : [  
> > > > "standard",  
> > > > "lowercase",  
> > > > "asciifolding"  
> > > > ],  
> > > > "type" : "custom",  
> > > > "tokenizer" : "standard"  
> > > > },  
> > > > "partial\_name" : {  
> > > > "filter" : [  
> > > > "standard",  
> > > > "lowercase",  
> > > > "asciifolding",  
> > > > "name\_ngrams"  
> > > > ],  
> > > > "type" : "custom",  
> > > > "tokenizer" : "standard"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > '
> 
> > > > Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [March 6, 2012, 12:28am UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/8 "2012-03-06T00:28:37Z")

</div>

I think you would use the default mapping:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--  
Matt Weber  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Monday, March 5, 2012 at 3:35 PM, quain wrote:

> Thanks a lot for pointing this out. This was the problem.
> 
> I was wondering, is it possible to apply this mapping to all types  
> within an index? For example, if I wanted to set the mapping for the  
> "name" field for all types of the index "test", can I do that?
> 
> On Mar 5, 12:33 pm, Garrick Evans \<[buk...@gmail.com](mailto:buk...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> 
> > You are posting to a "test" type but you created the mapping for "member".  
> > Try:
> > 
> > > curl - POST '[http://localhost:9200/test/member?pretty=true'-d](http://localhost:9200/test/member?pretty=true'-d) '{ "name" :  
> > > "The Office" }'  
> > > curl - POST '[http://localhost:9200/test/member?pretty=true'-d](http://localhost:9200/test/member?pretty=true'-d) '{ "name" :  
> > > "The Office (UK)" }'
> > 
> > You should then be able to query like:
> > 
> > > curl -XGEThttp://localhost:9200/test/\_search?pretty=1-d  
> > > '{"query":{"text":{"name.ngram":"th"}}}'  
> > > {  
> > > "took" : 1,  
> > > "timed\_out" : false,  
> > > "\_shards" : {  
> > > "total" : 5,  
> > > "successful" : 5,  
> > > "failed" : 0  
> > > },  
> > > "hits" : {  
> > > "total" : 2,  
> > > "max\_score" : 0.25,  
> > > "hits" : [ {  
> > > "\_index" : "test",  
> > > "\_type" : "member",  
> > > "\_id" : "MLleoK0pR8eBGhY9pkm0ig",  
> > > "\_score" : 0.25, "\_source" : { "name" : "The Office (UK)" }  
> > > }, {  
> > > "\_index" : "test",  
> > > "\_type" : "member",  
> > > "\_id" : "nzY1KZ6mRuqrzxosJBi9IQ",  
> > > "\_score" : 0.095891505, "\_source" : { "name" : "The Office" }  
> > > } ]  
> > > }
> > 
> > On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:
> > 
> > > Thanks, but I got the same result, still 0 hits. I didn't get a  
> > > syntax error the first time either, so not sure this is the problem.
> > 
> > > I thought I pretty much followed the documentation on this, not sure  
> > > why it doesn't work.
> > 
> > > On Mar 5, 10:35 am, Garrick Evans \<[buk...@gmail.com](mailto:buk...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > 
> > > > What if you
> > 
> > > > "query":{"text":{"name.ngram":"xyz"}}}
> > 
> > > > ?
> > 
> > > > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> > 
> > > > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > > > could shed some light on what I'm doing wrong. After I inserted some  
> > > > > documents, I get 0 hits for any searches of the field name.untouched  
> > > > > or name.ngram. I am successful with the main field just searching on  
> > > > > name. For example, the following returns nothing even though i know  
> > > > > the term is there exactly:
> > 
> > > > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > > > > {  
> > > > > "query" : {  
> > > > > "text" : {  
> > > > > "name.ngram" : {  
> > > > > "query" : "xyz"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > '
> > 
> > > > > Here's my mapping:
> > 
> > > > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > > > > {  
> > > > > "mappings" : {  
> > > > > "member" : {  
> > > > > "properties" : {  
> > > > > "name" : {  
> > > > > "type": "multi\_field",  
> > > > > "fields" : {  
> > > > > "untouched": {  
> > > > > "type": "string",  
> > > > > "index": "not\_analyzed"  
> > > > > },  
> > > > > "name": {  
> > > > > "type": "string",  
> > > > > "analyzer": "standard\_name"  
> > > > > },  
> > > > > "ngram" : {  
> > > > > "search\_analyzer": "standard\_name",  
> > > > > "index\_analyzer": "partial\_name",  
> > > > > "type": "string"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "settings" : {  
> > > > > "analysis" : {  
> > > > > "filter" : {  
> > > > > "name\_ngrams" : {  
> > > > > "side" : "front",  
> > > > > "max\_gram" : 10,  
> > > > > "min\_gram" : 1,  
> > > > > "type" : "edgeNGram"  
> > > > > }  
> > > > > },  
> > > > > "analyzer" : {  
> > > > > "standard\_name" : {  
> > > > > "filter" : [  
> > > > > "standard",  
> > > > > "lowercase",  
> > > > > "asciifolding"  
> > > > > ],  
> > > > > "type" : "custom",  
> > > > > "tokenizer" : "standard"  
> > > > > },  
> > > > > "partial\_name" : {  
> > > > > "filter" : [  
> > > > > "standard",  
> > > > > "lowercase",  
> > > > > "asciifolding",  
> > > > > "name\_ngrams"  
> > > > > ],  
> > > > > "type" : "custom",  
> > > > > "tokenizer" : "standard"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > '
> > 
> > > > > Can anyone give me some help to identify what might be wrong?  
> > > > > On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:
> > 
> > > Thanks, but I got the same result, still 0 hits. I didn't get a  
> > > syntax error the first time either, so not sure this is the problem.
> > 
> > > I thought I pretty much followed the documentation on this, not sure  
> > > why it doesn't work.
> > 
> > > On Mar 5, 10:35 am, Garrick Evans \<[buk...@gmail.com](mailto:buk...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > 
> > > > What if you
> > 
> > > > "query":{"text":{"name.ngram":"xyz"}}}
> > 
> > > > ?
> > 
> > > > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> > 
> > > > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > > > could shed some light on what I'm doing wrong. After I inserted some  
> > > > > documents, I get 0 hits for any searches of the field name.untouched  
> > > > > or name.ngram. I am successful with the main field just searching on  
> > > > > name. For example, the following returns nothing even though i know  
> > > > > the term is there exactly:
> > 
> > > > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > > > > {  
> > > > > "query" : {  
> > > > > "text" : {  
> > > > > "name.ngram" : {  
> > > > > "query" : "xyz"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > '
> > 
> > > > > Here's my mapping:
> > 
> > > > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > > > > {  
> > > > > "mappings" : {  
> > > > > "member" : {  
> > > > > "properties" : {  
> > > > > "name" : {  
> > > > > "type": "multi\_field",  
> > > > > "fields" : {  
> > > > > "untouched": {  
> > > > > "type": "string",  
> > > > > "index": "not\_analyzed"  
> > > > > },  
> > > > > "name": {  
> > > > > "type": "string",  
> > > > > "analyzer": "standard\_name"  
> > > > > },  
> > > > > "ngram" : {  
> > > > > "search\_analyzer": "standard\_name",  
> > > > > "index\_analyzer": "partial\_name",  
> > > > > "type": "string"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "settings" : {  
> > > > > "analysis" : {  
> > > > > "filter" : {  
> > > > > "name\_ngrams" : {  
> > > > > "side" : "front",  
> > > > > "max\_gram" : 10,  
> > > > > "min\_gram" : 1,  
> > > > > "type" : "edgeNGram"  
> > > > > }  
> > > > > },  
> > > > > "analyzer" : {  
> > > > > "standard\_name" : {  
> > > > > "filter" : [  
> > > > > "standard",  
> > > > > "lowercase",  
> > > > > "asciifolding"  
> > > > > ],  
> > > > > "type" : "custom",  
> > > > > "tokenizer" : "standard"  
> > > > > },  
> > > > > "partial\_name" : {  
> > > > > "filter" : [  
> > > > > "standard",  
> > > > > "lowercase",  
> > > > > "asciifolding",  
> > > > > "name\_ngrams"  
> > > > > ],  
> > > > > "type" : "custom",  
> > > > > "tokenizer" : "standard"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > '
> > 
> > > > > Can anyone give me some help to identify what might be wrong?

---

<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:** [March 6, 2012, 7:28pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/9 "2012-03-06T19:28:21Z")

</div>

Another option is to use dynamic templates: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html), and set it on a mapping called _default_ (which will apply to all types in the index).

On Tuesday, March 6, 2012 at 2:28 AM, Matt Weber wrote:

> I think you would use the default mapping:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping.html)
> 
> --  
> Matt Weber  
> Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))
> 
> On Monday, March 5, 2012 at 3:35 PM, quain wrote:
> 
> > Thanks a lot for pointing this out. This was the problem.
> > 
> > I was wondering, is it possible to apply this mapping to all types  
> > within an index? For example, if I wanted to set the mapping for the  
> > "name" field for all types of the index "test", can I do that?
> > 
> > On Mar 5, 12:33 pm, Garrick Evans \<[buk...@gmail.com](mailto:buk...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > 
> > > You are posting to a "test" type but you created the mapping for "member".  
> > > Try:
> > > 
> > > > curl - POST '[http://localhost:9200/test/member?pretty=true'-d](http://localhost:9200/test/member?pretty=true'-d) '{ "name" :  
> > > > "The Office" }'  
> > > > curl - POST '[http://localhost:9200/test/member?pretty=true'-d](http://localhost:9200/test/member?pretty=true'-d) '{ "name" :  
> > > > "The Office (UK)" }'
> > > 
> > > You should then be able to query like:
> > > 
> > > > curl -XGEThttp://localhost:9200/test/\_search?pretty=1-d  
> > > > '{"query":{"text":{"name.ngram":"th"}}}'  
> > > > {  
> > > > "took" : 1,  
> > > > "timed\_out" : false,  
> > > > "\_shards" : {  
> > > > "total" : 5,  
> > > > "successful" : 5,  
> > > > "failed" : 0  
> > > > },  
> > > > "hits" : {  
> > > > "total" : 2,  
> > > > "max\_score" : 0.25,  
> > > > "hits" : [ {  
> > > > "\_index" : "test",  
> > > > "\_type" : "member",  
> > > > "\_id" : "MLleoK0pR8eBGhY9pkm0ig",  
> > > > "\_score" : 0.25, "\_source" : { "name" : "The Office (UK)" }  
> > > > }, {  
> > > > "\_index" : "test",  
> > > > "\_type" : "member",  
> > > > "\_id" : "nzY1KZ6mRuqrzxosJBi9IQ",  
> > > > "\_score" : 0.095891505, "\_source" : { "name" : "The Office" }  
> > > > } ]  
> > > > }
> > > 
> > > On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:
> > > 
> > > > Thanks, but I got the same result, still 0 hits. I didn't get a  
> > > > syntax error the first time either, so not sure this is the problem.
> > > 
> > > > I thought I pretty much followed the documentation on this, not sure  
> > > > why it doesn't work.
> > > 
> > > > On Mar 5, 10:35 am, Garrick Evans \<[buk...@gmail.com](mailto:buk...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > 
> > > > > What if you
> > > 
> > > > > "query":{"text":{"name.ngram":"xyz"}}}
> > > 
> > > > > ?
> > > 
> > > > > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> > > 
> > > > > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > > > > could shed some light on what I'm doing wrong. After I inserted some  
> > > > > > documents, I get 0 hits for any searches of the field name.untouched  
> > > > > > or name.ngram. I am successful with the main field just searching on  
> > > > > > name. For example, the following returns nothing even though i know  
> > > > > > the term is there exactly:
> > > 
> > > > > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > > > > > {  
> > > > > > "query" : {  
> > > > > > "text" : {  
> > > > > > "name.ngram" : {  
> > > > > > "query" : "xyz"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > '
> > > 
> > > > > > Here's my mapping:
> > > 
> > > > > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > > > > > {  
> > > > > > "mappings" : {  
> > > > > > "member" : {  
> > > > > > "properties" : {  
> > > > > > "name" : {  
> > > > > > "type": "multi\_field",  
> > > > > > "fields" : {  
> > > > > > "untouched": {  
> > > > > > "type": "string",  
> > > > > > "index": "not\_analyzed"  
> > > > > > },  
> > > > > > "name": {  
> > > > > > "type": "string",  
> > > > > > "analyzer": "standard\_name"  
> > > > > > },  
> > > > > > "ngram" : {  
> > > > > > "search\_analyzer": "standard\_name",  
> > > > > > "index\_analyzer": "partial\_name",  
> > > > > > "type": "string"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > },  
> > > > > > "settings" : {  
> > > > > > "analysis" : {  
> > > > > > "filter" : {  
> > > > > > "name\_ngrams" : {  
> > > > > > "side" : "front",  
> > > > > > "max\_gram" : 10,  
> > > > > > "min\_gram" : 1,  
> > > > > > "type" : "edgeNGram"  
> > > > > > }  
> > > > > > },  
> > > > > > "analyzer" : {  
> > > > > > "standard\_name" : {  
> > > > > > "filter" : [  
> > > > > > "standard",  
> > > > > > "lowercase",  
> > > > > > "asciifolding"  
> > > > > > ],  
> > > > > > "type" : "custom",  
> > > > > > "tokenizer" : "standard"  
> > > > > > },  
> > > > > > "partial\_name" : {  
> > > > > > "filter" : [  
> > > > > > "standard",  
> > > > > > "lowercase",  
> > > > > > "asciifolding",  
> > > > > > "name\_ngrams"  
> > > > > > ],  
> > > > > > "type" : "custom",  
> > > > > > "tokenizer" : "standard"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > '
> > > 
> > > > > > Can anyone give me some help to identify what might be wrong?  
> > > > > > On Monday, March 5, 2012 11:10:51 AM UTC-8, quain wrote:
> > > 
> > > > Thanks, but I got the same result, still 0 hits. I didn't get a  
> > > > syntax error the first time either, so not sure this is the problem.
> > > 
> > > > I thought I pretty much followed the documentation on this, not sure  
> > > > why it doesn't work.
> > > 
> > > > On Mar 5, 10:35 am, Garrick Evans \<[buk...@gmail.com](mailto:buk...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > > > 
> > > > > What if you
> > > 
> > > > > "query":{"text":{"name.ngram":"xyz"}}}
> > > 
> > > > > ?
> > > 
> > > > > On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> > > 
> > > > > > I'm having some trouble with multi\_field, perhaps some of you guys  
> > > > > > could shed some light on what I'm doing wrong. After I inserted some  
> > > > > > documents, I get 0 hits for any searches of the field name.untouched  
> > > > > > or name.ngram. I am successful with the main field just searching on  
> > > > > > name. For example, the following returns nothing even though i know  
> > > > > > the term is there exactly:
> > > 
> > > > > > curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1'-d](http://127.0.0.1:9200/test/_search?pretty=1'-d) '  
> > > > > > {  
> > > > > > "query" : {  
> > > > > > "text" : {  
> > > > > > "name.ngram" : {  
> > > > > > "query" : "xyz"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > '
> > > 
> > > > > > Here's my mapping:
> > > 
> > > > > > curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1'-d](http://127.0.0.1:9200/test/?pretty=1'-d) '  
> > > > > > {  
> > > > > > "mappings" : {  
> > > > > > "member" : {  
> > > > > > "properties" : {  
> > > > > > "name" : {  
> > > > > > "type": "multi\_field",  
> > > > > > "fields" : {  
> > > > > > "untouched": {  
> > > > > > "type": "string",  
> > > > > > "index": "not\_analyzed"  
> > > > > > },  
> > > > > > "name": {  
> > > > > > "type": "string",  
> > > > > > "analyzer": "standard\_name"  
> > > > > > },  
> > > > > > "ngram" : {  
> > > > > > "search\_analyzer": "standard\_name",  
> > > > > > "index\_analyzer": "partial\_name",  
> > > > > > "type": "string"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > },  
> > > > > > "settings" : {  
> > > > > > "analysis" : {  
> > > > > > "filter" : {  
> > > > > > "name\_ngrams" : {  
> > > > > > "side" : "front",  
> > > > > > "max\_gram" : 10,  
> > > > > > "min\_gram" : 1,  
> > > > > > "type" : "edgeNGram"  
> > > > > > }  
> > > > > > },  
> > > > > > "analyzer" : {  
> > > > > > "standard\_name" : {  
> > > > > > "filter" : [  
> > > > > > "standard",  
> > > > > > "lowercase",  
> > > > > > "asciifolding"  
> > > > > > ],  
> > > > > > "type" : "custom",  
> > > > > > "tokenizer" : "standard"  
> > > > > > },  
> > > > > > "partial\_name" : {  
> > > > > > "filter" : [  
> > > > > > "standard",  
> > > > > > "lowercase",  
> > > > > > "asciifolding",  
> > > > > > "name\_ngrams"  
> > > > > > ],  
> > > > > > "type" : "custom",  
> > > > > > "tokenizer" : "standard"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > '
> > > 
> > > > > > Can anyone give me some help to identify what might be wrong?

---

<div class="post-metadata">

**Author:** ![quain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quain/32/2925_2.png) [@quain](https://discuss.elastic.co/u/quain)\
**Post date:** [April 12, 2012, 1:22am UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/10 "2012-04-12T01:22:03Z")

</div>

Bring back this old thread, but I have a followup question. Does edge  
ngram filtered fields support prefix or phrase-prefix queries? My goal is  
to prefer results which have the same word ordering as the query, ie if I  
search "Jack John" prefer "Jack Johnson" over "John Jackson". Can this be  
done via a query type/parameter, or custom scoring?

On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:

> I'm having some trouble with multi\_field, perhaps some of you guys  
> could shed some light on what I'm doing wrong. After I inserted some  
> documents, I get 0 hits for any searches of the field name.untouched  
> or name.ngram. I am successful with the main field just searching on  
> name. For example, the following returns nothing even though i know  
> the term is there exactly:
> 
> curl -XGET '[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)' -d '  
> {  
> "query" : {  
> "text" : {  
> "name.ngram" : {  
> "query" : "xyz"  
> }  
> }  
> }  
> }  
> '
> 
> Here's my mapping:
> 
> curl -XPUT '[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)' -d '  
> {  
> "mappings" : {  
> "member" : {  
> "properties" : {  
> "name" : {  
> "type": "multi\_field",  
> "fields" : {  
> "untouched": {  
> "type": "string",  
> "index": "not\_analyzed"  
> },  
> "name": {  
> "type": "string",  
> "analyzer": "standard\_name"  
> },  
> "ngram" : {  
> "search\_analyzer": "standard\_name",  
> "index\_analyzer": "partial\_name",  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> },  
> "settings" : {  
> "analysis" : {  
> "filter" : {  
> "name\_ngrams" : {  
> "side" : "front",  
> "max\_gram" : 10,  
> "min\_gram" : 1,  
> "type" : "edgeNGram"  
> }  
> },  
> "analyzer" : {  
> "standard\_name" : {  
> "filter" : [  
> "standard",  
> "lowercase",  
> "asciifolding"  
> ],  
> "type" : "custom",  
> "tokenizer" : "standard"  
> },  
> "partial\_name" : {  
> "filter" : [  
> "standard",  
> "lowercase",  
> "asciifolding",  
> "name\_ngrams"  
> ],  
> "type" : "custom",  
> "tokenizer" : "standard"  
> }  
> }  
> }  
> }  
> }  
> '
> 
> Can anyone give me some help to identify what might be wrong?

---

<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:** [April 13, 2012, 12:14pm UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/11 "2012-04-13T12:14:47Z")

</div>

You can execute a phrase query and boost it.

On Thu, Apr 12, 2012 at 4:22 AM, quain [quaintenance@gmail.com](mailto:quaintenance@gmail.com) wrote:

> Bring back this old thread, but I have a followup question. Does edge  
> ngram filtered fields support prefix or phrase-prefix queries? My goal is  
> to prefer results which have the same word ordering as the query, ie if I  
> search "Jack John" prefer "Jack Johnson" over "John Jackson". Can this be  
> done via a query type/parameter, or custom scoring?
> 
> On Sunday, March 4, 2012 11:07:04 PM UTC-8, quain wrote:
> 
> > I'm having some trouble with multi\_field, perhaps some of you guys  
> > could shed some light on what I'm doing wrong. After I inserted some  
> > documents, I get 0 hits for any searches of the field name.untouched  
> > or name.ngram. I am successful with the main field just searching on  
> > name. For example, the following returns nothing even though i know  
> > the term is there exactly:
> > 
> > curl -XGET '[http://127.0.0.1:9200/test/\_\*\*search?pretty=1](http://127.0.0.1:9200/test/_**search?pretty=1)[http://127.0.0.1:9200/test/\_search?pretty=1](http://127.0.0.1:9200/test/_search?pretty=1)'  
> > -d '  
> > {  
> > "query" : {  
> > "text" : {  
> > "name.ngram" : {  
> > "query" : "xyz"  
> > }  
> > }  
> > }  
> > }  
> > '
> > 
> > Here's my mapping:
> > 
> > curl -XPUT '[http://127.0.0.1:9200/test/?\*\*pretty=1](http://127.0.0.1:9200/test/?**pretty=1)[http://127.0.0.1:9200/test/?pretty=1](http://127.0.0.1:9200/test/?pretty=1)'  
> > -d '  
> > {  
> > "mappings" : {  
> > "member" : {  
> > "properties" : {  
> > "name" : {  
> > "type": "multi\_field",  
> > "fields" : {  
> > "untouched": {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > },  
> > "name": {  
> > "type": "string",  
> > "analyzer": "standard\_name"  
> > },  
> > "ngram" : {  
> > "search\_analyzer": "standard\_name",  
> > "index\_analyzer": "partial\_name",  
> > "type": "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "settings" : {  
> > "analysis" : {  
> > "filter" : {  
> > "name\_ngrams" : {  
> > "side" : "front",  
> > "max\_gram" : 10,  
> > "min\_gram" : 1,  
> > "type" : "edgeNGram"  
> > }  
> > },  
> > "analyzer" : {  
> > "standard\_name" : {  
> > "filter" : [  
> > "standard",  
> > "lowercase",  
> > "asciifolding"  
> > ],  
> > "type" : "custom",  
> > "tokenizer" : "standard"  
> > },  
> > "partial\_name" : {  
> > "filter" : [  
> > "standard",  
> > "lowercase",  
> > "asciifolding",  
> > "name\_ngrams"  
> > ],  
> > "type" : "custom",  
> > "tokenizer" : "standard"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > '
> > 
> > Can anyone give me some help to identify what might be wrong?

---

<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:32am UTC](https://discuss.elastic.co/t/question-about-multi-field-and-edge-ngram/6885/12 "2017-07-06T03:32:41Z")

</div>


