# The Analyzers and Terms

**URL:** https://discuss.elastic.co/t/the-analyzers-and-terms/10550
**Category:** Elasticsearch
**Created:** [January 30, 2013, 9:10am UTC](https://discuss.elastic.co/t/the-analyzers-and-terms/10550 "2013-01-30T09:10:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Curt\_Hu](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@Curt\_Hu](https://discuss.elastic.co/u/Curt_Hu)
#### Post date: [January 30, 2013, 9:10am UTC](https://discuss.elastic.co/t/the-analyzers-and-terms/10550/1 "2013-01-30T09:10:40Z")

</div>

Really got confused. Actually I want to the relationship between the analyzer and terms.  
I created a customer analyzer with a new index.  
curl -XPOST '[http://localhost:9200/curt](http://localhost:9200/curt)' -d '  
{  
"settings":{  
"analysis": {  
"analyzer": {  
"comma":{  
"type": "custom",  
"tokenizer": "commatokenizer"  
}  
},  
"tokenizer": {  
"commatokenizer":{  
"type": "pattern",  
"pattern": ","  
}  
}  
}  
}  
}'

Just use comma to separate the token.  
curl -XPUT '[http://localhost:9200/curt/jdbc/1](http://localhost:9200/curt/jdbc/1)' -d '{  
"keywords" : "foo,bar baz"  
}'

But When I do the following queries with terms facets:  
{  
"query": {  
"bool": {  
"must": [  
{  
"match\_all": {}  
}  
],  
"must\_not": [],  
"should": []  
}  
},  
"from": 0,  
"size": 50,  
"sort": [],  
"facets": {  
"termscount": {  
"terms": {  
"field": "keywords",  
"size": 25  
}  
}  
}  
}

Why I get the following outputs??  
"facets" : {  
"termscount" : {  
"\_type" : "terms",  
"missing" : 0,  
"total" : 3,  
"other" : 0,  
"terms" : [ {  
"term" : "foo",  
"count" : 1  
}, {  
"term" : "baz",  
"count" : 1  
}, {  
"term" : "bar",  
"count" : 1  
} ]  
}  
}

So there are 3 terms? Since I already use my analyzer to use comma to separate the words, so there should be 2 terms, right? Can anyone explain me on this?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 30, 2013, 9:14am UTC](https://discuss.elastic.co/t/the-analyzers-and-terms/10550/2 "2013-01-30T09:14:33Z")

</div>

Your concern here is that you create an analyzer but you did not apply it to your jdbc type.  
So, Elasticsearch uses the default mapping.

Use the PUT Mapping API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html)

Le 30 janv. 2013 à 10:10, Curt Hu [zhongting.hu@gmail.com](mailto:zhongting.hu@gmail.com) a écrit :

> Really got confused. Actually I want to the relationship between the analyzer  
> and terms.  
> I created a customer analyzer with a new index.  
> curl -XPOST '[http://localhost:9200/curt](http://localhost:9200/curt)' -d '  
> {  
> "settings":{  
> "analysis": {  
> "analyzer": {  
> "comma":{  
> "type": "custom",  
> "tokenizer": "commatokenizer"  
> }  
> },  
> "tokenizer": {  
> "commatokenizer":{  
> "type": "pattern",  
> "pattern": ","  
> }  
> }  
> }  
> }  
> }'
> 
> Just use comma to separate the token.  
> curl -XPUT '[http://localhost:9200/curt/jdbc/1](http://localhost:9200/curt/jdbc/1)' -d '{  
> "keywords" : "foo,bar baz"  
> }'
> 
> But When I do the following queries with terms facets:  
> {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "match\_all": {}  
> }  
> ],  
> "must\_not": ,  
> "should":   
> }  
> },  
> "from": 0,  
> "size": 50,  
> "sort": ,  
> "facets": {  
> "termscount": {  
> "terms": {  
> "field": "keywords",  
> "size": 25  
> }  
> }  
> }  
> }
> 
> Why I get the following outputs??  
> "facets" : {  
> "termscount" : {  
> "\_type" : "terms",  
> "missing" : 0,  
> "total" : 3,  
> "other" : 0,  
> "terms" : [ {  
> "term" : "foo",  
> "count" : 1  
> }, {  
> "term" : "baz",  
> "count" : 1  
> }, {  
> "term" : "bar",  
> "count" : 1  
> } ]  
> }  
> }
> 
> So there are 3 terms? Since I already use my analyzer to use comma to  
> separate the words, so there should be 2 terms, right? Can anyone explain me  
> on this?
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003.html](http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Curt\_Hu](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@Curt\_Hu](https://discuss.elastic.co/u/Curt_Hu)
#### Post date: [February 1, 2013, 10:35am UTC](https://discuss.elastic.co/t/the-analyzers-and-terms/10550/3 "2013-02-01T10:35:35Z")

</div>

Hi, dadoonet  
Thanks very much for your rely, I still got a little confused on this.  
I need to apply the analyzer to the specific type? (for me example, is jdbc),  
How could I do that by put mapping api? Thanks.  
  
Your concern here is that you create an analyzer but you did not apply it to your jdbc type.  
So, Elasticsearch uses the default mapping.

Use the PUT Mapping API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html)

Le 30 janv. 2013 à 10:10, Curt Hu \<zhongting.hu@\> a écrit :

> Really got confused. Actually I want to the relationship between the analyzer  
> and terms.  
> I created a customer analyzer with a new index.  
> curl -XPOST '[http://localhost:9200/curt](http://localhost:9200/curt)' -d '  
> {  
> "settings":{  
> "analysis": {  
> "analyzer": {  
> "comma":{  
> "type": "custom",  
> "tokenizer": "commatokenizer"  
> }  
> },  
> "tokenizer": {  
> "commatokenizer":{  
> "type": "pattern",  
> "pattern": ","  
> }  
> }  
> }  
> }  
> }'
> 
> Just use comma to separate the token.  
> curl -XPUT '[http://localhost:9200/curt/jdbc/1](http://localhost:9200/curt/jdbc/1)' -d '{  
> "keywords" : "foo,bar baz"  
> }'
> 
> But When I do the following queries with terms facets:  
> {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "match\_all": {}  
> }  
> ],  
> "must\_not": ,  
> "should":   
> }  
> },  
> "from": 0,  
> "size": 50,  
> "sort": ,  
> "facets": {  
> "termscount": {  
> "terms": {  
> "field": "keywords",  
> "size": 25  
> }  
> }  
> }  
> }
> 
> Why I get the following outputs??  
> "facets" : {  
> "termscount" : {  
> "\_type" : "terms",  
> "missing" : 0,  
> "total" : 3,  
> "other" : 0,  
> "terms" : [ {  
> "term" : "foo",  
> "count" : 1  
> }, {  
> "term" : "baz",  
> "count" : 1  
> }, {  
> "term" : "bar",  
> "count" : 1  
> } ]  
> }  
> }
> 
> So there are 3 terms? Since I already use my analyzer to use comma to  
> separate the words, so there should be 2 terms, right? Can anyone explain me  
> on this?
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003.html](http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@.  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 1, 2013, 11:01pm UTC](https://discuss.elastic.co/t/the-analyzers-and-terms/10550/4 "2013-02-01T23:01:23Z")

</div>

What you did not understand in the link I mentioned before?

Did you try it? What command did you send and what answer do you have?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 févr. 2013 à 11:35, Curt Hu [zhongting.hu@gmail.com](mailto:zhongting.hu@gmail.com) a écrit :

Hi, dadoonet  
Thanks very much for your rely, I still got a little confused on this.  
I need to apply the analyzer to the specific type? (for me example, is  
jdbc),  
How could I do that by put mapping api? Thanks.

dadoonet wrote

> Your concern here is that you create an analyzer but you did not apply it  
> to your jdbc type.  
> So, Elasticsearch uses the default mapping.
> 
> Use the PUT Mapping API:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html)
> 
> Le 30 janv. 2013 à 10:10, Curt Hu \<

> zhongting.hu@

> \> a écrit :
> 
> > Really got confused. Actually I want to the relationship between the  
> > analyzer  
> > and terms.  
> > I created a customer analyzer with a new index.  
> > curl -XPOST '[http://localhost:9200/curt](http://localhost:9200/curt)' -d '  
> > {  
> > "settings":{  
> > "analysis": {  
> > "analyzer": {  
> > "comma":{  
> > "type": "custom",  
> > "tokenizer": "commatokenizer"  
> > }  
> > },  
> > "tokenizer": {  
> > "commatokenizer":{  
> > "type": "pattern",  
> > "pattern": ","  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > Just use comma to separate the token.  
> > curl -XPUT '[http://localhost:9200/curt/jdbc/1](http://localhost:9200/curt/jdbc/1)' -d '{  
> > "keywords" : "foo,bar baz"  
> > }'
> > 
> > But When I do the following queries with terms facets:  
> > {  
> > "query": {  
> > "bool": {  
> > "must": [  
> > {  
> > "match\_all": {}  
> > }  
> > ],  
> > "must\_not": ,  
> > "should":   
> > }  
> > },  
> > "from": 0,  
> > "size": 50,  
> > "sort": ,  
> > "facets": {  
> > "termscount": {  
> > "terms": {  
> > "field": "keywords",  
> > "size": 25  
> > }  
> > }  
> > }  
> > }
> > 
> > Why I get the following outputs??  
> > "facets" : {  
> > "termscount" : {  
> > "\_type" : "terms",  
> > "missing" : 0,  
> > "total" : 3,  
> > "other" : 0,  
> > "terms" : [ {  
> > "term" : "foo",  
> > "count" : 1  
> > }, {  
> > "term" : "baz",  
> > "count" : 1  
> > }, {  
> > "term" : "bar",  
> > "count" : 1  
> > } ]  
> > }  
> > }
> > 
> > So there are 3 terms? Since I already use my analyzer to use comma to  
> > separate the words, so there should be 2 terms, right? Can anyone explain  
> > me  
> > on this?
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003.html](http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to

> elasticsearch+unsubscribe@

> .
> 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to

> elasticsearch+unsubscribe@

> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003p4029172.html](http://elasticsearch-users.115913.n3.nabble.com/The-Analyzers-and-Terms-tp4029003p4029172.html)  
Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:53am UTC](https://discuss.elastic.co/t/the-analyzers-and-terms/10550/5 "2017-07-06T02:53:26Z")

</div>


