# How to use analyzer from plugin?

**URL:** <https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773>\
**Category:** Elasticsearch\
**Created:** [August 17, 2012, 5:23pm UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773 "2012-08-17T17:23:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Radford](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@Michael\_Radford](https://discuss.elastic.co/u/Michael_Radford)\
**Post date:** [August 17, 2012, 5:23pm UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773/1 "2012-08-17T17:23:58Z")

</div>

I have the Smart Chinese Analysis plugin installed in elasticsearch 0.19.3  
(via bin/plugin -install  
elasticsearch/elasticsearch-analysis-smartcn/1.2.0), and I'm just trying to  
see the analysis results using command lines like this:

curl -XGET '[http://localhost:9200/\_analyze?analyzer=smart\_chinese](http://localhost:9200/_analyze?analyzer=smart_chinese)' -d  
'{"body":"油画"}'

but this gives the error:  
{"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
[smart\_chinese]]","status":400}

From the logs, it does look like the plugin is being loaded:  
[2012-08-17 17:15:35,928][INFO][plugins] [Wong] loaded  
[analysis-smartcn, cloud-aws], sites []

It does work if I ask for "analyzer=english" or "analyzer=chinese". So I  
must be missing some configuration somewhere? (I can't find any  
configuration for "english" or other built-in analyzers, so I'm a bit  
confused.)

Thanks,  
Mike

--

---

<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:** [August 17, 2012, 5:49pm UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773/2 "2012-08-17T17:49:05Z")

</div>

Look inside the code for the actual binding. The standard ones are  
defined in AnalysisModule, but for at the code where it registers the  
plugin. It appears that the smart chinese analyzer is bound via  
"smartcn".

[https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java](https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java)

Cheers,

Ivan

On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford [mubber@gmail.com](mailto:mubber@gmail.com) wrote:

> I have the Smart Chinese Analysis plugin installed in elasticsearch 0.19.3  
> (via bin/plugin -install  
> elasticsearch/elasticsearch-analysis-smartcn/1.2.0), and I'm just trying to  
> see the analysis results using command lines like this:
> 
> curl -XGET '[http://localhost:9200/\_analyze?analyzer=smart\_chinese](http://localhost:9200/_analyze?analyzer=smart_chinese)' -d  
> '{"body":"油画"}'
> 
> but this gives the error:  
> {"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
> [smart\_chinese]]","status":400}
> 
> From the logs, it does look like the plugin is being loaded:  
> [2012-08-17 17:15:35,928][INFO][plugins] [Wong] loaded  
> [analysis-smartcn, cloud-aws], sites
> 
> It does work if I ask for "analyzer=english" or "analyzer=chinese". So I  
> must be missing some configuration somewhere? (I can't find any  
> configuration for "english" or other built-in analyzers, so I'm a bit  
> confused.)
> 
> Thanks,  
> Mike
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Michael\_Radford](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@Michael\_Radford](https://discuss.elastic.co/u/Michael_Radford)\
**Post date:** [August 17, 2012, 5:54pm UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773/3 "2012-08-17T17:54:43Z")

</div>

"analyzer=smartcn" doesn't work either:

$ curl -XGET '[http://localhost:9200/\_analyze?analyzer=smartcn](http://localhost:9200/_analyze?analyzer=smartcn)' -d  
'{"body":"油画"}'  
{"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
[smartcn]]","status":400}

(Nor does "tokenizer=smartcn\_sentence".)

With the plugin loaded (apparently), is there some other configuration  
necessary to get these bindings?

Mike

On Friday, August 17, 2012 10:49:05 AM UTC-7, Ivan Brusic wrote:

> Look inside the code for the actual binding. The standard ones are  
> defined in AnalysisModule, but for at the code where it registers the  
> plugin. It appears that the smart chinese analyzer is bound via  
> "smartcn".
> 
> [https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java](https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java)
> 
> Cheers,
> 
> Ivan
> 
> On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford \<[mub...@gmail.com](mailto:mub...@gmail.com)\<javascript:\>\>  
> wrote:
> 
> > I have the Smart Chinese Analysis plugin installed in elasticsearch  
> > 0.19.3  
> > (via bin/plugin -install  
> > elasticsearch/elasticsearch-analysis-smartcn/1.2.0), and I'm just trying  
> > to  
> > see the analysis results using command lines like this:
> > 
> > curl -XGET '[http://localhost:9200/\_analyze?analyzer=smart\_chinese](http://localhost:9200/_analyze?analyzer=smart_chinese)' -d  
> > '{"body":"油画"}'
> > 
> > but this gives the error:  
> > {"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
> > [smart\_chinese]]","status":400}
> > 
> > From the logs, it does look like the plugin is being loaded:  
> > [2012-08-17 17:15:35,928][INFO][plugins] [Wong]  
> > loaded  
> > [analysis-smartcn, cloud-aws], sites
> > 
> > It does work if I ask for "analyzer=english" or "analyzer=chinese". So I  
> > must be missing some configuration somewhere? (I can't find any  
> > configuration for "english" or other built-in analyzers, so I'm a bit  
> > confused.)
> > 
> > Thanks,  
> > Mike
> > 
> > --

--

---

<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:** [August 17, 2012, 6:00pm UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773/4 "2012-08-17T18:00:52Z")

</div>

Not sure about plugins, but for custom analyzers, you need to first  
create an index that references the analyzer. The plugin could  
potentially have the same issue.

On Fri, Aug 17, 2012 at 10:54 AM, Michael Radford [mubber@gmail.com](mailto:mubber@gmail.com) wrote:

> "analyzer=smartcn" doesn't work either:
> 
> $ curl -XGET '[http://localhost:9200/\_analyze?analyzer=smartcn](http://localhost:9200/_analyze?analyzer=smartcn)' -d  
> '{"body":"油画"}'  
> {"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
> [smartcn]]","status":400}
> 
> (Nor does "tokenizer=smartcn\_sentence".)
> 
> With the plugin loaded (apparently), is there some other configuration  
> necessary to get these bindings?
> 
> Mike
> 
> On Friday, August 17, 2012 10:49:05 AM UTC-7, Ivan Brusic wrote:
> 
> > Look inside the code for the actual binding. The standard ones are  
> > defined in AnalysisModule, but for at the code where it registers the  
> > plugin. It appears that the smart chinese analyzer is bound via  
> > "smartcn".
> > 
> > [https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java](https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java)
> > 
> > Cheers,
> > 
> > Ivan
> > 
> > On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford [mub...@gmail.com](mailto:mub...@gmail.com)  
> > wrote:
> > 
> > > I have the Smart Chinese Analysis plugin installed in elasticsearch  
> > > 0.19.3  
> > > (via bin/plugin -install  
> > > elasticsearch/elasticsearch-analysis-smartcn/1.2.0), and I'm just trying  
> > > to  
> > > see the analysis results using command lines like this:
> > > 
> > > curl -XGET '[http://localhost:9200/\_analyze?analyzer=smart\_chinese](http://localhost:9200/_analyze?analyzer=smart_chinese)' -d  
> > > '{"body":"油画"}'
> > > 
> > > but this gives the error:  
> > > {"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
> > > [smart\_chinese]]","status":400}
> > > 
> > > From the logs, it does look like the plugin is being loaded:  
> > > [2012-08-17 17:15:35,928][INFO][plugins] [Wong]  
> > > loaded  
> > > [analysis-smartcn, cloud-aws], sites
> > > 
> > > It does work if I ask for "analyzer=english" or "analyzer=chinese". So I  
> > > must be missing some configuration somewhere? (I can't find any  
> > > configuration for "english" or other built-in analyzers, so I'm a bit  
> > > confused.)
> > > 
> > > Thanks,  
> > > Mike
> > > 
> > > --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Michael\_Radford](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@Michael\_Radford](https://discuss.elastic.co/u/Michael_Radford)\
**Post date:** [August 17, 2012, 9:14pm UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773/5 "2012-08-17T21:14:56Z")

</div>

Thanks, the smart\_chinese analyzer does seem to be working after creating  
an index that references it.

More specifically, asking for it by name still fails, but the index  
settings update call succeeds, and I can see that the analysis results  
differ from the standard analyzer. (I guess there must be a specific list  
of analyzers available via "analyzer=whatever" as query parameters. Or  
maybe they're only picked up from index configuration at startup time, or  
whatever.)

In case it helps anyone else, all I did was:

$ curl -XPUT '[http://localhost:9200/global/](http://localhost:9200/global/)' -d '  
{  
"settings": {  
"index": {  
"analysis": {  
"analyzer": {  
"default": {  
"type": "smart\_chinese"  
}  
}  
}  
}  
}  
}  
'  
{"ok":true,"acknowledged":true}

and then it appears to be working:

$ curl '[http://localhost:9200/global/\_analyze?pretty=true](http://localhost:9200/global/_analyze?pretty=true)' -d '油画'  
{  
"tokens" : [ {  
"token" : "油画",  
"start\_offset" : 0,  
"end\_offset" : 2,  
"type" : "word",  
"position" : 1  
} ]  
}

vs. the standard analyzer:

$ curl  
'[http://localhost:9200/global/\_analyze?pretty=true&analyzer=standard](http://localhost:9200/global/_analyze?pretty=true&analyzer=standard)' -d  
'油画'{  
"tokens" : [ {  
"token" : "油",  
"start\_offset" : 0,  
"end\_offset" : 1,  
"type" : "",  
"position" : 1  
}, {  
"token" : "画",  
"start\_offset" : 1,  
"end\_offset" : 2,  
"type" : "",  
"position" : 2  
} ]  
}

However:

$ curl  
'[http://localhost:9200/global/\_analyze?pretty=true&analyzer=smart\_chinese](http://localhost:9200/global/_analyze?pretty=true&analyzer=smart_chinese)'  
-d '油画'  
{  
"error" : "ElasticSearchIllegalArgumentException[failed to find analyzer  
[smart\_chinese]]",  
"status" : 400  
}

Mike

On Friday, August 17, 2012 11:00:52 AM UTC-7, Ivan Brusic wrote:

> Not sure about plugins, but for custom analyzers, you need to first  
> create an index that references the analyzer. The plugin could  
> potentially have the same issue.
> 
> On Fri, Aug 17, 2012 at 10:54 AM, Michael Radford \<[mub...@gmail.com](mailto:mub...@gmail.com)\<javascript:\>\>  
> wrote:
> 
> > "analyzer=smartcn" doesn't work either:
> > 
> > $ curl -XGET '[http://localhost:9200/\_analyze?analyzer=smartcn](http://localhost:9200/_analyze?analyzer=smartcn)' -d  
> > '{"body":"油画"}'  
> > {"error":"ElasticSearchIllegalArgumentException[failed to find analyzer  
> > [smartcn]]","status":400}
> > 
> > (Nor does "tokenizer=smartcn\_sentence".)
> > 
> > With the plugin loaded (apparently), is there some other configuration  
> > necessary to get these bindings?
> > 
> > Mike
> > 
> > On Friday, August 17, 2012 10:49:05 AM UTC-7, Ivan Brusic wrote:
> > 
> > > Look inside the code for the actual binding. The standard ones are  
> > > defined in AnalysisModule, but for at the code where it registers the  
> > > plugin. It appears that the smart chinese analyzer is bound via  
> > > "smartcn".
> 
> [https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java](https://github.com/elasticsearch/elasticsearch-analysis-smartcn/blob/master/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java)
> 
> > > Cheers,
> > > 
> > > Ivan
> > > 
> > > On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford [mub...@gmail.com](mailto:mub...@gmail.com)  
> > > wrote:
> > > 
> > > > I have the Smart Chinese Analysis plugin installed in elasticsearch  
> > > > 0.19.3  
> > > > (via bin/plugin -install  
> > > > elasticsearch/elasticsearch-analysis-smartcn/1.2.0), and I'm just  
> > > > trying  
> > > > to  
> > > > see the analysis results using command lines like this:
> > > > 
> > > > curl -XGET '[http://localhost:9200/\_analyze?analyzer=smart\_chinese](http://localhost:9200/_analyze?analyzer=smart_chinese)'  
> > > > -d  
> > > > '{"body":"油画"}'
> > > > 
> > > > but this gives the error:  
> > > > {"error":"ElasticSearchIllegalArgumentException[failed to find  
> > > > analyzer  
> > > > [smart\_chinese]]","status":400}
> > > > 
> > > > From the logs, it does look like the plugin is being loaded:  
> > > > [2012-08-17 17:15:35,928][INFO][plugins] [Wong]  
> > > > loaded  
> > > > [analysis-smartcn, cloud-aws], sites
> > > > 
> > > > It does work if I ask for "analyzer=english" or "analyzer=chinese".  
> > > > So I  
> > > > must be missing some configuration somewhere? (I can't find any  
> > > > configuration for "english" or other built-in analyzers, so I'm a bit  
> > > > confused.)
> > > > 
> > > > Thanks,  
> > > > Mike
> > > > 
> > > > --
> > 
> > --

--

---

<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:16am UTC](https://discuss.elastic.co/t/how-to-use-analyzer-from-plugin/8773/6 "2017-07-06T03:16:00Z")

</div>


