How to use analyzer from plugin?


(Michael Radford) #1

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' -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

--


(Ivan Brusic) #2

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

Cheers,

Ivan

On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford 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' -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

--

--


(Michael Radford) #3

"analyzer=smartcn" doesn't work either:

$ curl -XGET '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

Cheers,

Ivan

On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford <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' -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

--

--


(Ivan Brusic) #4

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 wrote:

"analyzer=smartcn" doesn't work either:

$ curl -XGET '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

Cheers,

Ivan

On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford 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' -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

--

--

--


(Michael Radford) #5

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/' -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' -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' -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'
-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<javascript:>>
wrote:

"analyzer=smartcn" doesn't work either:

$ curl -XGET '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

Cheers,

Ivan

On Fri, Aug 17, 2012 at 10:23 AM, Michael Radford 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'
-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

--

--

--


(system) #6