# How could I set "mapping type" via "put mapping API"?

**URL:** <https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569>\
**Category:** Elasticsearch\
**Created:** [May 5, 2012, 4:53pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569 "2012-05-05T16:53:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yang](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@Yang](https://discuss.elastic.co/u/Yang)\
**Post date:** [May 5, 2012, 4:53pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/1 "2012-05-05T16:53:12Z")

</div>

Dear all,

I'm playing with facet of ES, it's very convenience for my sub navigation.

But here I meet a problem:

my data just like:

{"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
{"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
{"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
{"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}

{"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
{"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
{"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
{"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
{"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}

//I just execute the es java api like below:  
TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
facetUN.fields("username");  
TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
facetMT.fields("mtype");  
...  
searchRequest.addFacet(facetUN);  
searchRequest.addFacet(facetMT);  
... execute search request and get the response

I just want to get a facet result like this:  
username:  
jacky sun(4)  
yang sun(5)  
media type:  
mp4(4)  
rmvb(5)

But the actual result is:  
username:  
sun(9)  
jacky(4)  
yang(5)  
media type:  
mp4(4)  
rmvb(5)

Then I realized "jacky sun" had been tokenized.

After I saw the info under  
[http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html) ,  
it's telling me to set the field(username) as "not\_analyzed".

Because I don't know how to set it via java client, I just execute the  
setting request like this on Win7:

C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
{properties : {username : {type : """string""", index :  
"""not\_analyzed"""}}}}"

Then I got the error:  
{"error":"ActionRequestValidationException[Validation Failed: 1: mapping  
type is missing;]","status":500}

Could anybody tell me where could I put the "mapping type" or "type" in the  
url above?

Or is there any other way to make "jacky sun" not to be tokenized?

thanks,

--  
Yang

---

<div class="post-metadata">

**Author:** ![anjesh](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@anjesh](https://discuss.elastic.co/u/anjesh)\
**Post date:** [May 5, 2012, 5:09pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/2 "2012-05-05T17:09:08Z")

</div>

I think this is what you are looking. I had a similar problem.  
[http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087)

Best  
Anjesh

On 5 May 2012 22:38, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:

> Dear all,
> 
> I'm playing with facet of ES, it's very convenience for my sub navigation.
> 
> But here I meet a problem:
> 
> my data just like:
> 
> {"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
> {"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
> {"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
> {"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
> 
> {"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
> {"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
> {"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
> {"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
> {"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
> 
> //I just execute the es java api like below:  
> TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
> facetUN.fields("username");  
> TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
> facetMT.fields("mtype");  
> ...  
> searchRequest.addFacet(facetUN);  
> searchRequest.addFacet(facetMT);  
> ... execute search request and get the response
> 
> I just want to get a facet result like this:  
> username:  
> jacky sun(4)  
> yang sun(5)  
> media type:  
> mp4(4)  
> rmvb(5)
> 
> But the actual result is:  
> username:  
> sun(9)  
> jacky(4)  
> yang(5)  
> media type:  
> mp4(4)  
> rmvb(5)
> 
> Then I realized "jacky sun" had been tokenized.
> 
> After I saw the info under  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html) ,  
> it's telling me to set the field(username) as "not\_analyzed".
> 
> Because I don't know how to set it via java client, I just execute the  
> setting request like this on Win7:
> 
> C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
> {properties : {username : {type : """string""", index :  
> """not\_analyzed"""}}}}"
> 
> Then I got the error:  
> {"error":"ActionRequestValidationException[Validation Failed: 1: mapping  
> type is missing;]","status":500}
> 
> Could anybody tell me where could I put the "mapping type" or "type" in  
> the url above?
> 
> Or is there any other way to make "jacky sun" not to be tokenized?
> 
> thanks,
> 
> --  
> Yang

---

<div class="post-metadata">

**Author:** ![Yang](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@Yang](https://discuss.elastic.co/u/Yang)\
**Post date:** [May 5, 2012, 5:24pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/3 "2012-05-05T17:24:37Z")

</div>

WOW~~

Thanks anjesh for replying so quick.

I read the info you gave, we do meet the same problem, and it seems there  
is no final solution, right?

On Sunday, May 6, 2012 1:09:08 AM UTC+8, anjesh wrote:

> I think this is what you are looking. I had a similar problem.  
> [http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087)
> 
> Best  
> Anjesh
> 
> On 5 May 2012 22:38, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:
> 
> > Dear all,
> > 
> > I'm playing with facet of ES, it's very convenience for my sub navigation.
> > 
> > But here I meet a problem:
> > 
> > my data just like:
> > 
> > {"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
> > {"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
> > {"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
> > {"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
> > 
> > {"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
> > {"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
> > {"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
> > {"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
> > {"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
> > 
> > //I just execute the es java api like below:  
> > TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
> > facetUN.fields("username");  
> > TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
> > facetMT.fields("mtype");  
> > ...  
> > searchRequest.addFacet(facetUN);  
> > searchRequest.addFacet(facetMT);  
> > ... execute search request and get the response
> > 
> > I just want to get a facet result like this:  
> > username:  
> > jacky sun(4)  
> > yang sun(5)  
> > media type:  
> > mp4(4)  
> > rmvb(5)
> > 
> > But the actual result is:  
> > username:  
> > sun(9)  
> > jacky(4)  
> > yang(5)  
> > media type:  
> > mp4(4)  
> > rmvb(5)
> > 
> > Then I realized "jacky sun" had been tokenized.
> > 
> > After I saw the info under  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html) ,  
> > it's telling me to set the field(username) as "not\_analyzed".
> > 
> > Because I don't know how to set it via java client, I just execute the  
> > setting request like this on Win7:
> > 
> > C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
> > {properties : {username : {type : """string""", index :  
> > """not\_analyzed"""}}}}"
> > 
> > Then I got the error:  
> > {"error":"ActionRequestValidationException[Validation Failed: 1: mapping  
> > type is missing;]","status":500}
> > 
> > Could anybody tell me where could I put the "mapping type" or "type" in  
> > the url above?
> > 
> > Or is there any other way to make "jacky sun" not to be tokenized?
> > 
> > thanks,
> > 
> > --  
> > Yang

---

<div class="post-metadata">

**Author:** ![Yang](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@Yang](https://discuss.elastic.co/u/Yang)\
**Post date:** [May 5, 2012, 5:28pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/4 "2012-05-05T17:28:17Z")

</div>

And also, the error told me to set "mapping type", do you know how I could  
put it via the url below?  
C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
{properties : {username : {type : """string""", index :  
"""not\_analyzed"""}}}}"

On Sunday, May 6, 2012 1:24:37 AM UTC+8, Yang wrote:

> WOW~~
> 
> Thanks anjesh for replying so quick.
> 
> I read the info you gave, we do meet the same problem, and it seems there  
> is no final solution, right?
> 
> On Sunday, May 6, 2012 1:09:08 AM UTC+8, anjesh wrote:
> 
> > I think this is what you are looking. I had a similar problem.  
> > [http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087)
> > 
> > Best  
> > Anjesh
> > 
> > On 5 May 2012 22:38, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:
> > 
> > > Dear all,
> > > 
> > > I'm playing with facet of ES, it's very convenience for my sub  
> > > navigation.
> > > 
> > > But here I meet a problem:
> > > 
> > > my data just like:
> > > 
> > > {"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
> > > {"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
> > > {"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
> > > {"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
> > > 
> > > {"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
> > > {"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
> > > {"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
> > > {"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
> > > {"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
> > > 
> > > //I just execute the es java api like below:  
> > > TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
> > > facetUN.fields("username");  
> > > TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
> > > facetMT.fields("mtype");  
> > > ...  
> > > searchRequest.addFacet(facetUN);  
> > > searchRequest.addFacet(facetMT);  
> > > ... execute search request and get the response
> > > 
> > > I just want to get a facet result like this:  
> > > username:  
> > > jacky sun(4)  
> > > yang sun(5)  
> > > media type:  
> > > mp4(4)  
> > > rmvb(5)
> > > 
> > > But the actual result is:  
> > > username:  
> > > sun(9)  
> > > jacky(4)  
> > > yang(5)  
> > > media type:  
> > > mp4(4)  
> > > rmvb(5)
> > > 
> > > Then I realized "jacky sun" had been tokenized.
> > > 
> > > After I saw the info under  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html) ,  
> > > it's telling me to set the field(username) as "not\_analyzed".
> > > 
> > > Because I don't know how to set it via java client, I just execute the  
> > > setting request like this on Win7:
> > > 
> > > C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
> > > {properties : {username : {type : """string""", index :  
> > > """not\_analyzed"""}}}}"
> > > 
> > > Then I got the error:  
> > > {"error":"ActionRequestValidationException[Validation Failed: 1: mapping  
> > > type is missing;]","status":500}
> > > 
> > > Could anybody tell me where could I put the "mapping type" or "type" in  
> > > the url above?
> > > 
> > > Or is there any other way to make "jacky sun" not to be tokenized?
> > > 
> > > thanks,
> > > 
> > > --  
> > > Yang

---

<div class="post-metadata">

**Author:** ![anjesh\_2](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@anjesh\_2](https://discuss.elastic.co/u/anjesh_2)\
**Post date:** [May 5, 2012, 5:36pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/5 "2012-05-05T17:36:34Z")

</div>

Hi Yang,

I have found the solution that worked for me. Follow the gist here  
[http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964932](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964932)

Try analyser:keyword instead of index:not\_analyzed in mapping.

curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword : {properties  
: {username : {type : """string""", analyzer : """keyword"""}}}}"

Honestly i haven't understood in details. But it worked for me so far.

Anjesh.

On 5 May 2012 23:13, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:

> And also, the error told me to set "mapping type", do you know how I could  
> put it via the url below?  
> C:\>curl -XPUT [http://localhost:9200/\_all/\_\*\*mapping](http://localhost:9200/_all/_**mapping)[http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d  
> " {fullword : {properties : {username : {type : """string""", index :  
> """not\_analyzed"""}}}}"
> 
> On Sunday, May 6, 2012 1:24:37 AM UTC+8, Yang wrote:
> 
> > WOW~~
> > 
> > Thanks anjesh for replying so quick.
> > 
> > I read the info you gave, we do meet the same problem, and it seems there  
> > is no final solution, right?
> > 
> > On Sunday, May 6, 2012 1:09:08 AM UTC+8, anjesh wrote:
> > 
> > > I think this is what you are looking. I had a similar problem.  
> > > http://elasticsearch-**[users.115913.n3.nabble.com/](http://users.115913.n3.nabble.com/)**  
> > > need-count-of-terms-using- **facets-taking-space-into-**  
> > > account-td3956699.html#\*\*a3964087[http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087)
> > > 
> > > Best  
> > > Anjesh
> > > 
> > > On 5 May 2012 22:38, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:
> > > 
> > > > Dear all,
> > > > 
> > > > I'm playing with facet of ES, it's very convenience for my sub  
> > > > navigation.
> > > > 
> > > > But here I meet a problem:
> > > > 
> > > > my data just like:
> > > > 
> > > > {"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
> > > > {"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
> > > > {"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
> > > > {"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
> > > > 
> > > > {"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
> > > > 
> > > > //I just execute the es java api like below:  
> > > > TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
> > > > facetUN.fields("username");  
> > > > TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
> > > > facetMT.fields("mtype");  
> > > > ...  
> > > > searchRequest.addFacet(\*\*facetUN);  
> > > > searchRequest.addFacet(\*\*facetMT);  
> > > > ... execute search request and get the response
> > > > 
> > > > I just want to get a facet result like this:  
> > > > username:  
> > > > jacky sun(4)  
> > > > yang sun(5)  
> > > > media type:  
> > > > mp4(4)  
> > > > rmvb(5)
> > > > 
> > > > But the actual result is:  
> > > > username:  
> > > > sun(9)  
> > > > jacky(4)  
> > > > yang(5)  
> > > > media type:  
> > > > mp4(4)  
> > > > rmvb(5)
> > > > 
> > > > Then I realized "jacky sun" had been tokenized.
> > > > 
> > > > After I saw the info under [http://www](http://www).**[Elastic — The Search AI Company | Elastic](http://elasticsearch.org/guide/)**  
> > > > reference/index-modules/\*\*analysis/keyword-analyzer.html[http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html)  
> > > > \*\* , it's telling me to set the field(username) as "not\_analyzed".
> > > > 
> > > > Because I don't know how to set it via java client, I just execute the  
> > > > setting request like this on Win7:
> > > > 
> > > > C:\>curl -XPUT [http://localhost:9200/\_all/\_\*\*mapping](http://localhost:9200/_all/_**mapping)[http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping)-d " {fullword : {properties : {username : {type : """string""", index :  
> > > > """not\_analyzed"""}}}}"
> > > > 
> > > > Then I got the error:  
> > > > {"error":" **ActionRequestValidationExcepti** on[Validation Failed: 1:  
> > > > mapping type is missing;]","status":500}
> > > > 
> > > > Could anybody tell me where could I put the "mapping type" or "type" in  
> > > > the url above?
> > > > 
> > > > Or is there any other way to make "jacky sun" not to be tokenized?
> > > > 
> > > > thanks,
> > > > 
> > > > --  
> > > > Yang

--

## _Anjesh Tuladhar_ Chief Operations Officer

## YoungInnovations Pvt. Ltd. GPO 8976 EPC 241 Pulchowk, Lalitpur, Nepal

## P: +977-1-5009282 W: [http://yipl.com.np](http://yipl.com.np) E: info@yipl.com.np

## Skype: anjesh.tuladhar

## _DISCLAIMER_ This email contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.

---

<div class="post-metadata">

**Author:** ![Yang](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@Yang](https://discuss.elastic.co/u/Yang)\
**Post date:** [May 5, 2012, 6:08pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/6 "2012-05-05T18:08:54Z")

</div>

cool, I will try what you did, just make it work.

On Sunday, May 6, 2012 1:36:34 AM UTC+8, anjesh wrote:

> Hi Yang,
> 
> I have found the solution that worked for me. Follow the gist here  
> [http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964932](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964932)
> 
> Try analyser:keyword instead of index:not\_analyzed in mapping.
> 
> curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
> {properties : {username : {type : """string""", analyzer :  
> """keyword"""}}}}"
> 
> Honestly i haven't understood in details. But it worked for me so far.
> 
> Anjesh.
> 
> On 5 May 2012 23:13, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:
> 
> > And also, the error told me to set "mapping type", do you know how I  
> > could put it via the url below?  
> > C:\>curl -XPUT [http://localhost:9200/\_all/\_\*\*mapping](http://localhost:9200/_all/_**mapping)[http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d  
> > " {fullword : {properties : {username : {type : """string""", index :  
> > """not\_analyzed"""}}}}"
> > 
> > On Sunday, May 6, 2012 1:24:37 AM UTC+8, Yang wrote:
> > 
> > > WOW~~
> > > 
> > > Thanks anjesh for replying so quick.
> > > 
> > > I read the info you gave, we do meet the same problem, and it seems  
> > > there is no final solution, right?
> > > 
> > > On Sunday, May 6, 2012 1:09:08 AM UTC+8, anjesh wrote:
> > > 
> > > > I think this is what you are looking. I had a similar problem.  
> > > > http://elasticsearch-**[users.115913.n3.nabble.com/](http://users.115913.n3.nabble.com/)**  
> > > > need-count-of-terms-using- **facets-taking-space-into-**  
> > > > account-td3956699.html#\*\*a3964087[http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087)
> > > > 
> > > > Best  
> > > > Anjesh
> > > > 
> > > > On 5 May 2012 22:38, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:
> > > > 
> > > > > Dear all,
> > > > > 
> > > > > I'm playing with facet of ES, it's very convenience for my sub  
> > > > > navigation.
> > > > > 
> > > > > But here I meet a problem:
> > > > > 
> > > > > my data just like:
> > > > > 
> > > > > {"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
> > > > > {"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
> > > > > {"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
> > > > > {"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
> > > > > 
> > > > > {"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
> > > > > {"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
> > > > > {"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
> > > > > {"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
> > > > > {"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
> > > > > 
> > > > > //I just execute the es java api like below:  
> > > > > TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
> > > > > facetUN.fields("username");  
> > > > > TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
> > > > > facetMT.fields("mtype");  
> > > > > ...  
> > > > > searchRequest.addFacet(\*\*facetUN);  
> > > > > searchRequest.addFacet(\*\*facetMT);  
> > > > > ... execute search request and get the response
> > > > > 
> > > > > I just want to get a facet result like this:  
> > > > > username:  
> > > > > jacky sun(4)  
> > > > > yang sun(5)  
> > > > > media type:  
> > > > > mp4(4)  
> > > > > rmvb(5)
> > > > > 
> > > > > But the actual result is:  
> > > > > username:  
> > > > > sun(9)  
> > > > > jacky(4)  
> > > > > yang(5)  
> > > > > media type:  
> > > > > mp4(4)  
> > > > > rmvb(5)
> > > > > 
> > > > > Then I realized "jacky sun" had been tokenized.
> > > > > 
> > > > > After I saw the info under [http://www](http://www).**[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/guide/)**  
> > > > > reference/index-modules/\*\*analysis/keyword-analyzer.html[http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html)  
> > > > > \*\* , it's telling me to set the field(username) as "not\_analyzed".
> > > > > 
> > > > > Because I don't know how to set it via java client, I just execute the  
> > > > > setting request like this on Win7:
> > > > > 
> > > > > C:\>curl -XPUT [http://localhost:9200/\_all/\_\*\*mapping](http://localhost:9200/_all/_**mapping)[http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping)-d " {fullword : {properties : {username : {type : """string""", index :  
> > > > > """not\_analyzed"""}}}}"
> > > > > 
> > > > > Then I got the error:  
> > > > > {"error":" **ActionRequestValidationExcepti** on[Validation Failed: 1:  
> > > > > mapping type is missing;]","status":500}
> > > > > 
> > > > > Could anybody tell me where could I put the "mapping type" or "type"  
> > > > > in the url above?
> > > > > 
> > > > > Or is there any other way to make "jacky sun" not to be tokenized?
> > > > > 
> > > > > thanks,
> > > > > 
> > > > > --  
> > > > > Yang
> 
> --
> 
> ## _Anjesh Tuladhar_ Chief Operations Officer
> 
> ## YoungInnovations Pvt. Ltd. GPO 8976 EPC 241 Pulchowk, Lalitpur, Nepal
> 
> ## P: +977-1-5009282 W: [http://yipl.com.np](http://yipl.com.np) E: info@yipl.com.np
> 
> ## Skype: anjesh.tuladhar
> 
> ## _DISCLAIMER_ This email contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 7, 2012, 4:59pm UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/7 "2012-05-07T16:59:35Z")

</div>

Strange, although the code registers REST handler for PUT mappings  
without types (line 49), the code itself appears to require them (line  
59).

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java#L49](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java#L49)

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java#L79](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java#L79)

Try simply adding a type in your REST request. Also not sure if a PUT  
mapping will work on \_all.

--  
Ivan

On Sat, May 5, 2012 at 10:28 AM, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:

> And also, the error told me to set "mapping type", do you know how I could  
> put it via the url below?  
> C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
> {properties : {username : {type : """string""", index :  
> """not\_analyzed"""}}}}"
> 
> On Sunday, May 6, 2012 1:24:37 AM UTC+8, Yang wrote:
> 
> > WOW~~
> > 
> > Thanks anjesh for replying so quick.
> > 
> > I read the info you gave, we do meet the same problem, and it seems there  
> > is no final solution, right?
> > 
> > On Sunday, May 6, 2012 1:09:08 AM UTC+8, anjesh wrote:
> > 
> > > I think this is what you are looking. I had a similar  
> > > problem. [http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087](http://elasticsearch-users.115913.n3.nabble.com/need-count-of-terms-using-facets-taking-space-into-account-td3956699.html#a3964087)
> > > 
> > > Best  
> > > Anjesh
> > > 
> > > On 5 May 2012 22:38, Yang [yuyang030405@gmail.com](mailto:yuyang030405@gmail.com) wrote:
> > > 
> > > > Dear all,
> > > > 
> > > > I'm playing with facet of ES, it's very convenience for my sub  
> > > > navigation.
> > > > 
> > > > But here I meet a problem:
> > > > 
> > > > my data just like:
> > > > 
> > > > {"username":"jacky sun", "mname":"abc1.mp4", "mtype":"mp4"}  
> > > > {"username":"jacky sun", "mname":"abc2.mp4", "mtype":"mp4"}  
> > > > {"username":"jacky sun", "mname":"abc3.mp4", "mtype":"mp4"}  
> > > > {"username":"jacky sun", "mname":"abc4.mp4", "mtype":"mp4"}
> > > > 
> > > > {"username":"yang sun", "mname":"abc1.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc2.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc3.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc4.rmvb", "mtype":"rmvb"}  
> > > > {"username":"yang sun", "mname":"abc5.rmvb", "mtype":"rmvb"}
> > > > 
> > > > //I just execute the es java api like below:  
> > > > TermsFacetBuilder facetUN = new TermsFacetBuilder("username");  
> > > > facetUN.fields("username");  
> > > > TermsFacetBuilder facetMT = new TermsFacetBuilder("mtype");  
> > > > facetMT.fields("mtype");  
> > > > ...  
> > > > searchRequest.addFacet(facetUN);  
> > > > searchRequest.addFacet(facetMT);  
> > > > ... execute search request and get the response
> > > > 
> > > > I just want to get a facet result like this:  
> > > > username:  
> > > > jacky sun(4)  
> > > > yang sun(5)  
> > > > media type:  
> > > > mp4(4)  
> > > > rmvb(5)
> > > > 
> > > > But the actual result is:  
> > > > username:  
> > > > sun(9)  
> > > > jacky(4)  
> > > > yang(5)  
> > > > media type:  
> > > > mp4(4)  
> > > > rmvb(5)
> > > > 
> > > > Then I realized "jacky sun" had been tokenized.
> > > > 
> > > > After I saw the info  
> > > > under [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html) ,  
> > > > it's telling me to set the field(username) as "not\_analyzed".
> > > > 
> > > > Because I don't know how to set it via java client, I just execute the  
> > > > setting request like this on Win7:
> > > > 
> > > > C:\>curl -XPUT [http://localhost:9200/\_all/\_mapping](http://localhost:9200/_all/_mapping) -d " {fullword :  
> > > > {properties : {username : {type : """string""", index :  
> > > > """not\_analyzed"""}}}}"
> > > > 
> > > > Then I got the error:  
> > > > {"error":"ActionRequestValidationException[Validation Failed: 1: mapping  
> > > > type is missing;]","status":500}
> > > > 
> > > > Could anybody tell me where could I put the "mapping type" or "type" in  
> > > > the url above?
> > > > 
> > > > Or is there any other way to make "jacky sun" not to be tokenized?
> > > > 
> > > > thanks,
> > > > 
> > > > --  
> > > > Yang

---

<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:29am UTC](https://discuss.elastic.co/t/how-could-i-set-mapping-type-via-put-mapping-api/7569/8 "2017-07-06T03:29:54Z")

</div>


