# Field analyzer usage

**URL:** https://discuss.elastic.co/t/field-analyzer-usage/5997
**Category:** Elasticsearch
**Created:** [November 28, 2011, 4:27pm UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997 "2011-11-28T16:27:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sisu\_Alexandru](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sisu\_Alexandru](https://discuss.elastic.co/u/Sisu_Alexandru)
#### Post date: [November 28, 2011, 4:27pm UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997/1 "2011-11-28T16:27:58Z")

</div>

Hi,

I have a mapping and a setting, and the "body" field doesn't gets analyzed  
by the "x\_analyzer".

MAPPING = {  
"posting":  
{

```
        "properties":
                {
                "country": {"type": "integer", "store": "yes"},
                "username": {"type": "string", "store": "yes"},
                "body": {"type": "string", "store": "yes", "index":

```

"analyzed", "analyzer": "x\_analyzer"},  
}  
}

and the index creation setting:

SETTINGS = {  
"index": {  
"number\_of\_shards": 1  
}  
,  
"analysis": {  
"analyzer": {  
"x\_analyzer": {  
"type": "com.xyz.elasticsearch.analysis.XAnalyzerProvider"  
},  
}

So, it doesnt work.What am I doing wrong?

Tnx,

Alex

ps: If I change the "x\_analyzer" to "default" and  
remove "analyzer": "x\_analyzer" from the mapping, everything goes okey.

---

<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: [November 28, 2011, 6:24pm UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997/2 "2011-11-28T18:24:24Z")

</div>

What doesn't work? That would help a bit...

On Mon, Nov 28, 2011 at 6:27 PM, Sisu Alexandru [sisu.eugen@gmail.com](mailto:sisu.eugen@gmail.com)wrote:

> Hi,
> 
> I have a mapping and a setting, and the "body" field doesn't gets analyzed  
> by the "x\_analyzer".
> 
> MAPPING = {  
> "posting":  
> {
> 
> ```
> "properties":
> {
> "country": {"type": "integer", "store": "yes"},
> "username": {"type": "string", "store": "yes"},
> "body": {"type": "string", "store": "yes", "index":
> 
> ```
> 
> "analyzed", "analyzer": "x\_analyzer"},  
> }  
> }
> 
> and the index creation setting:
> 
> SETTINGS = {  
> "index": {  
> "number\_of\_shards": 1  
> }  
> ,  
> "analysis": {  
> "analyzer": {  
> "x\_analyzer": {  
> "type": "com.xyz.elasticsearch.analysis.XAnalyzerProvider"  
> },  
> }
> 
> So, it doesnt work.What am I doing wrong?
> 
> Tnx,
> 
> Alex
> 
> ps: If I change the "x\_analyzer" to "default" and  
> remove "analyzer": "x\_analyzer" from the mapping, everything goes okey.

---

<div class="post-metadata">

### Author: ![Sisu\_Alexandru](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sisu\_Alexandru](https://discuss.elastic.co/u/Sisu_Alexandru)
#### Post date: [November 28, 2011, 10:46pm UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997/3 "2011-11-28T22:46:05Z")

</div>

Well, the body field is not indexed by the x\_analyzer.  
Actually all the fields are indexed by the standardanalyzer.

Other info:  
My es configuration, doesn't have anything configured in the  
elasticsearch.yml.  
When I'm changing the name of the x\_analyzer to default, it works.

On Mon, Nov 28, 2011 at 7:24 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> What doesn't work? That would help a bit...
> 
> On Mon, Nov 28, 2011 at 6:27 PM, Sisu Alexandru [sisu.eugen@gmail.com](mailto:sisu.eugen@gmail.com)wrote:
> 
> > Hi,
> > 
> > I have a mapping and a setting, and the "body" field doesn't gets  
> > analyzed by the "x\_analyzer".
> > 
> > MAPPING = {  
> > "posting":  
> > {
> > 
> > ```
> > "properties":
> > {
> > "country": {"type": "integer", "store": "yes"},
> > "username": {"type": "string", "store": "yes"},
> > "body": {"type": "string", "store": "yes", "index":
> > 
> > ```
> > 
> > "analyzed", "analyzer": "x\_analyzer"},  
> > }  
> > }
> > 
> > and the index creation setting:
> > 
> > SETTINGS = {  
> > "index": {  
> > "number\_of\_shards": 1  
> > }  
> > ,  
> > "analysis": {  
> > "analyzer": {  
> > "x\_analyzer": {  
> > "type": "com.xyz.elasticsearch.analysis.XAnalyzerProvider"  
> > },  
> > }
> > 
> > So, it doesnt work.What am I doing wrong?
> > 
> > Tnx,
> > 
> > Alex
> > 
> > ps: If I change the "x\_analyzer" to "default" and  
> > remove "analyzer": "x\_analyzer" from the mapping, everything goes okey.

---

<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: [November 29, 2011, 7:52am UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997/4 "2011-11-29T07:52:14Z")

</div>

It might be the settings that you provide, I think your analyzer is not  
configured correctly, try and put the analysis config under the "index"  
element (same as number\_of\_shards). If it doesn't work, add a debug  
statement to your custom analyzer provider, see if it gets created at all.

On Tue, Nov 29, 2011 at 12:46 AM, Sisu Alexandru [sisu.eugen@gmail.com](mailto:sisu.eugen@gmail.com)wrote:

> Well, the body field is not indexed by the x\_analyzer.  
> Actually all the fields are indexed by the standardanalyzer.
> 
> Other info:  
> My es configuration, doesn't have anything configured in the  
> elasticsearch.yml.  
> When I'm changing the name of the x\_analyzer to default, it works.
> 
> On Mon, Nov 28, 2011 at 7:24 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > What doesn't work? That would help a bit...
> > 
> > On Mon, Nov 28, 2011 at 6:27 PM, Sisu Alexandru [sisu.eugen@gmail.com](mailto:sisu.eugen@gmail.com)wrote:
> > 
> > > Hi,
> > > 
> > > I have a mapping and a setting, and the "body" field doesn't gets  
> > > analyzed by the "x\_analyzer".
> > > 
> > > MAPPING = {  
> > > "posting":  
> > > {
> > > 
> > > ```
> > > "properties":
> > > {
> > > "country": {"type": "integer", "store": "yes"},
> > > "username": {"type": "string", "store": "yes"},
> > > "body": {"type": "string", "store": "yes", "index":
> > > 
> > > ```
> > > 
> > > "analyzed", "analyzer": "x\_analyzer"},  
> > > }  
> > > }
> > > 
> > > and the index creation setting:
> > > 
> > > SETTINGS = {  
> > > "index": {  
> > > "number\_of\_shards": 1  
> > > }  
> > > ,  
> > > "analysis": {  
> > > "analyzer": {  
> > > "x\_analyzer": {  
> > > "type":  
> > > "com.xyz.elasticsearch.analysis.XAnalyzerProvider"  
> > > },  
> > > }
> > > 
> > > So, it doesnt work.What am I doing wrong?
> > > 
> > > Tnx,
> > > 
> > > Alex
> > > 
> > > ps: If I change the "x\_analyzer" to "default" and  
> > > remove "analyzer": "x\_analyzer" from the mapping, everything goes okey.

---

<div class="post-metadata">

### Author: ![Sisu\_Alexandru](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sisu\_Alexandru](https://discuss.elastic.co/u/Sisu_Alexandru)
#### Post date: [November 29, 2011, 11:36am UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997/5 "2011-11-29T11:36:16Z")

</div>

Tnx for the answer.  
It turned out that it was my mistake. I was sending the mapping in an  
incorrect way..  
Here is the mistake:

MAPPING = {  
"posting":  
{

```
        "properties":
                {
                "country": {"type": "integer", "store": "yes"},
                "username": {"type": "string", "store": "yes"},
                "body": {"type": "string", "store": "yes", "index":

```

"analyzed", "analyzer": "x\_analyzer"},  
}  
}

I was doing: mapping\_res = conn.put\_mapping("posting", {'properties':  
MAPPING}, ["testindex"])

The problem was that I already had this 2 elements (!posting! and  
!properties!) defined in the MAPPING dict.

So, the MAPPING is now:  
MAPPING = {  
"country": {"type": "integer", "store": "yes"},  
"username": {"type": "string", "store": "yes"},  
"body": {"type": "string", "store": "yes", "index":  
"analyzed", "analyzer": "x\_analyzer"},  
}

and the INDEX SETTING is as you've said:  
SETTINGS = {  
"index": {  
"number\_of\_shards": 1,  
"analysis": {  
"analyzer": {  
"x\_analyzer": {  
"type": "com.xyz.elasticsearch.analysis.XAnalyzerProvider"  
},

```
}

```

}

On Tue, Nov 29, 2011 at 8:52 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> It might be the settings that you provide, I think your analyzer is not  
> configured correctly, try and put the analysis config under the "index"  
> element (same as number\_of\_shards). If it doesn't work, add a debug  
> statement to your custom analyzer provider, see if it gets created at all.
> 
> On Tue, Nov 29, 2011 at 12:46 AM, Sisu Alexandru [sisu.eugen@gmail.com](mailto:sisu.eugen@gmail.com)wrote:
> 
> > Well, the body field is not indexed by the x\_analyzer.  
> > Actually all the fields are indexed by the standardanalyzer.
> > 
> > Other info:  
> > My es configuration, doesn't have anything configured in the  
> > elasticsearch.yml.  
> > When I'm changing the name of the x\_analyzer to default, it works.
> > 
> > On Mon, Nov 28, 2011 at 7:24 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > 
> > > What doesn't work? That would help a bit...
> > > 
> > > On Mon, Nov 28, 2011 at 6:27 PM, Sisu Alexandru [sisu.eugen@gmail.com](mailto:sisu.eugen@gmail.com)wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I have a mapping and a setting, and the "body" field doesn't gets  
> > > > analyzed by the "x\_analyzer".
> > > > 
> > > > MAPPING = {  
> > > > "posting":  
> > > > {
> > > > 
> > > > ```
> > > > "properties":
> > > > {
> > > > "country": {"type": "integer", "store": "yes"},
> > > > "username": {"type": "string", "store": "yes"},
> > > > "body": {"type": "string", "store": "yes", "index":
> > > > 
> > > > ```
> > > > 
> > > > "analyzed", "analyzer": "x\_analyzer"},  
> > > > }  
> > > > }
> > > > 
> > > > and the index creation setting:
> > > > 
> > > > SETTINGS = {  
> > > > "index": {  
> > > > "number\_of\_shards": 1  
> > > > }  
> > > > ,  
> > > > "analysis": {  
> > > > "analyzer": {  
> > > > "x\_analyzer": {  
> > > > "type":  
> > > > "com.xyz.elasticsearch.analysis.XAnalyzerProvider"  
> > > > },  
> > > > }
> > > > 
> > > > So, it doesnt work.What am I doing wrong?
> > > > 
> > > > Tnx,
> > > > 
> > > > Alex
> > > > 
> > > > ps: If I change the "x\_analyzer" to "default" and  
> > > > remove "analyzer": "x\_analyzer" from the mapping, everything goes okey.

---

<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:47am UTC](https://discuss.elastic.co/t/field-analyzer-usage/5997/6 "2017-07-06T03:47:06Z")

</div>


