Recently I've upgrade ES from 2.1.0 to ES 5.2.2, which also using the analysis-mmseg plugin. I've followed the procedure to rebuild the plugin, change the index setting. And after restart ES, everything seems ok.
Here's the index mapping:
{
"users" : {
"mappings" : {
"user" : {
"dynamic" : "false",
"properties" : {
"analyzed_name" : {
"type" : "text",
"analyzer" : "mmseg_maxword"
},
"id" : {
"type" : "integer"
},
"likes_count" : {
"type" : "integer"
},
"nickname" : {
"type" : "keyword",
"copy_to" : [
"analyzed_name"
]
}
}
}
}
}
}
When I make a simple query, the output become randomly:
curl 'localhost:9200/users/_search?pretty' -d '{
"query": {
"bool": {
"should": [
{
"match_phrase": {
"nickname": {
"query": "十分",
"boost": 100
}
}
},
{
"match_phrase": {
"analyzed_name": {
"query": "十分",
"boost": 50,
"slop": 10
}
}
},
{
"prefix": {
"analyzed_name": "十分"
}
},
{
"match": {
"analyzed_name": "十分"
}
}
],
"minimum_should_match": 1
}
}
}'
Expected Output:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 35,
"successful": 35,
"failed": 0
},
"hits": {
"total": 166,
"max_score": 2012.748,
"hits": [
{
"_index": "users",
"_type": "user",
"_id": "1210186",
"_score": 2012.748,
"_source": {
"nickname": "十分",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "2466113",
"_score": 734.9008,
"_source": {
"nickname": "十分十分",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "2493231",
"_score": 626.3631,
"_source": {
"nickname": "十分十分er",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "47203",
"_score": 533.75287,
"_source": {
"nickname": "十分tenmin",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "530063",
"_score": 533.75287,
"_source": {
"nickname": "落日十分",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "3305185",
"_score": 533.75287,
"_source": {
"nickname": "九点十分",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "3334990",
"_score": 533.75287,
"_source": {
"nickname": "日出十分",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "4382556",
"_score": 533.75287,
"_source": {
"nickname": "十分好奇",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "4441797",
"_score": 533.75287,
"_source": {
"nickname": "黎明十分",
"likes_count": 1
}
},
{
"_index": "users",
"_type": "user",
"_id": "2615409",
"_score": 527.52295,
"_source": {
"nickname": "林十分",
"likes_count": 1
}
}
]
}
}
Actually result:
{
"error" : {
"root_cause" : [
{
"type" : "query_shard_exception",
"reason" : "failed to create query: {\n \"bool\" : {\n \"should\" : [\n {\n \"match_phrase\" : {\n \"nickname\" : {\n \"query\" : \"十分\",\n \"slop\" : 0,\n \"boost\" : 100.0\n }\n }\n },\n {\n \"match_phrase\" : {\n \"analyzed_name\" : {\n \"query\" : \"十分\",\n \"slop\" : 10,\n \"boost\" : 50.0\n }\n }\n },\n {\n \"prefix\" : {\n \"analyzed_name\" : {\n \"value\" : \"十分\",\n \"boost\" : 1.0\n }\n }\n },\n {\n \"match\" : {\n \"analyzed_name\" : {\n \"query\" : \"十分\",\n \"operator\" : \"OR\",\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"fuzzy_transpositions\" : true,\n \"lenient\" : false,\n \"zero_terms_query\" : \"NONE\",\n \"boost\" : 1.0\n }\n }\n }\n ],\n \"disable_coord\" : false,\n \"adjust_pure_negative\" : true,\n \"minimum_should_match\" : \"1\",\n \"boost\" : 1.0\n }\n}",
"index_uuid" : "G5kCglksQQmnc21W7nJnAw",
"index" : "users"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "users",
"node" : "HDqZAuQORYeeLHmmhsEMTQ",
"reason" : {
"type" : "query_shard_exception",
"reason" : "failed to create query: {\n \"bool\" : {\n \"should\" : [\n {\n \"match_phrase\" : {\n \"nickname\" : {\n \"query\" : \"十分\",\n \"slop\" : 0,\n \"boost\" : 100.0\n }\n }\n },\n {\n \"match_phrase\" : {\n \"analyzed_name\" : {\n \"query\" : \"十分\",\n \"slop\" : 10,\n \"boost\" : 50.0\n }\n }\n },\n {\n \"prefix\" : {\n \"analyzed_name\" : {\n \"value\" : \"十分\",\n \"boost\" : 1.0\n }\n }\n },\n {\n \"match\" : {\n \"analyzed_name\" : {\n \"query\" : \"十分\",\n \"operator\" : \"OR\",\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"fuzzy_transpositions\" : true,\n \"lenient\" : false,\n \"zero_terms_query\" : \"NONE\",\n \"boost\" : 1.0\n }\n }\n }\n ],\n \"disable_coord\" : false,\n \"adjust_pure_negative\" : true,\n \"minimum_should_match\" : \"1\",\n \"boost\" : 1.0\n }\n}",
"index_uuid" : "G5kCglksQQmnc21W7nJnAw",
"index" : "users",
"caused_by" : {
"type" : "null_pointer_exception",
"reason" : null
}
}
}
],
"caused_by" : {
"type" : "query_shard_exception",
"reason" : "failed to create query: {\n \"bool\" : {\n \"should\" : [\n {\n \"match_phrase\" : {\n \"nickname\" : {\n \"query\" : \"十分\",\n \"slop\" : 0,\n \"boost\" : 100.0\n }\n }\n },\n {\n \"match_phrase\" : {\n \"analyzed_name\" : {\n \"query\" : \"十分\",\n \"slop\" : 10,\n \"boost\" : 50.0\n }\n }\n },\n {\n \"prefix\" : {\n \"analyzed_name\" : {\n \"value\" : \"十分\",\n \"boost\" : 1.0\n }\n }\n },\n {\n \"match\" : {\n \"analyzed_name\" : {\n \"query\" : \"十分\",\n \"operator\" : \"OR\",\n \"prefix_length\" : 0,\n \"max_expansions\" : 50,\n \"fuzzy_transpositions\" : true,\n \"lenient\" : false,\n \"zero_terms_query\" : \"NONE\",\n \"boost\" : 1.0\n }\n }\n }\n ],\n \"disable_coord\" : false,\n \"adjust_pure_negative\" : true,\n \"minimum_should_match\" : \"1\",\n \"boost\" : 1.0\n }\n}",
"index_uuid" : "G5kCglksQQmnc21W7nJnAw",
"index" : "users",
"caused_by" : {
"type" : "null_pointer_exception",
"reason" : null
}
}
},
"status" : 400
}
The Elasticsearch Log:
Caused by: org.elasticsearch.index.query.QueryShardException: failed to create query: {
"bool" : {
"should" : [
{
"match_phrase" : {
"nickname" : {
"query" : "十分",
"slop" : 0,
"boost" : 100.0
}
}
},
{
"match_phrase" : {
"analyzed_name" : {
"query" : "十分",
"slop" : 10,
"boost" : 50.0
}
}
},
{
"prefix" : {
"nickname" : {
"value" : "十分",
"boost" : 1.0
}
}
},
{
"match" : {
"analyzed_name" : {
"query" : "十分",
"operator" : "OR",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"minimum_should_match" : "1",
"boost" : 1.0
}
}
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:333) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:311) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:671) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.search.SearchService.createContext(SearchService.java:540) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:516) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:251) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:298) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:295) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610) [elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596) [elasticsearch-5.2.2.jar:5.2.2]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.2.2.jar:5.2.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: java.lang.NullPointerException
at com.chenlb.mmseg4j.rule.MaxMatchRule.isRemove(MaxMatchRule.java:28) ~[?:?]
at com.chenlb.mmseg4j.rule.Rule.remainChunks(Rule.java:40) ~[?:?]
at com.chenlb.mmseg4j.ComplexSeg.seg(ComplexSeg.java:96) ~[?:?]
at com.chenlb.mmseg4j.MaxWordSeg.seg(MaxWordSeg.java:19) ~[?:?]
at com.chenlb.mmseg4j.MMSeg.next(MMSeg.java:178) ~[?:?]
at com.chenlb.mmseg4j.analysis.MMSegTokenizer.incrementToken(MMSegTokenizer.java:64) ~[?:?]
at org.apache.lucene.analysis.LowerCaseFilter.incrementToken(LowerCaseFilter.java:44) ~[lucene-core-6.4.1.jar:6.4.1 72f75b2503fa0aa4f0aff76d439874feb923bb0e - jpountz - 2017-02-01 14:43:32]
Any help is appreciated.