我想知道分析器(在elasticsearch中)应该只在主节点上实现,还是必须分别在所有节点上实现?
找不到准确的答案。
请帮忙!
谢谢
{
filter: {
spanish_stemmer: {
type: "stemmer",
language: "spanish"
},
spanish_stop: {
type: "stop",
stopwords: "_spanish_"
}
},
my_analyzer: {
spanish: {
filter: [
"lowercase",
"spanish_stop",
"spanish_stemmer"
],
tokenizer: "standard"
}
},
mappings: {
customparent: {
properties: {
name: {
type: "string",
analyzer: "my_analyzer"
},
title: {
type: "string",
analyzer: "my_analyzer"
},
fullImageAltDescription: {
type: "string",
analyzer: "my_analyzer"
}
}
}
}
}

添加日志: -
我正在使用Elasticsearch(2.4.1v)Spring数据传输客户端从elasticsearch获取数据时遇到以下错误: -
org.elasticsearch.action.search.SearchPhaseExecutionException:所有分片都失败了 在org.elasticsearch.action.search.AbstractSearchAsyncAction.onFirstPhaseResult(AbstractSearchAsyncAction.java:206)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.action.search.AbstractSearchAsyncAction $ 1.onFailure(AbstractSearchAsyncAction.java:152)〜[elasticsearch-2.4.0.jar:2.4.0] at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:46)〜[elasticsearch-2.4.0.jar:2.4.0] at org.elasticsearch.transport.TransportService $ DirectResponseChannel.processException(TransportService.java:872)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.transport.TransportService $ DirectResponseChannel.sendResponse(TransportService.java:850)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.transport.TransportService $ 4.onFailure(TransportService.java:387)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39)〜[elasticsearch-2.4.0.jar:2.4.0] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)〜[na:1.8.0_101] at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)〜[na:1.8.0_101] 在java.lang.Thread.run(Thread.java:748)〜[na:1.8.0_101] 引起:org.elasticsearch.index.query.QueryParsingException:找不到[match] analyzer [my_analyzer] 在org.elasticsearch.index.query.MatchQueryParser.parse(MatchQueryParser.java:101)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:250)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:320)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:218)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.search.SearchService.parseSource(SearchService.java:856)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.search.SearchService.createContext(SearchService.java:667)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:264)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.search.action.SearchServiceTransportAction $ SearchDfsTransportHandler.messageReceived(SearchServiceTransportAction.java:360)〜[elasticsearch-2.4.0.jar:2.4.0] at org.elasticsearch.search.action.SearchServiceTransportAction $ SearchDfsTransportHandler.messageReceived(SearchServiceTransportAction.java:357)〜[elasticsearch-2.4.0.jar:2.4.0] at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)〜[elasticsearch-2.4.0.jar:2.4.0] at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.transport.TransportService $ 4.doRun(TransportService.java:376)〜[elasticsearch-2.4.0.jar:2.4.0] 在org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)〜[elasticsearch-2.4.0.jar:2.4.0] ...省略了3个常见帧 00:52:06.100 [http-bio-8080-exec-3] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - SecurityContext为空或内容为匿名 - 上下文不会存储在HttpSession中。 00:52:06.100 [http-bio-8080-exec-3] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder现已清除,请求处理完成 2017年9月5日12:52:06 org.apache.catalina.core.StandardWrapperValve调用 严重:Servlet [appServlet]的Servlet.service()在路径[/ api]的上下文中引发异常[请求处理失败;嵌套异常无法执行阶段[dfs],所有分片都失败; shardFailures {[tdPbTD9IQhSuvkFMYt1WbA] [catalogviews] [0]:RemoteTransportException [[Shellshock] [my_ip:9300] [indices:data / read / search [phase / dfs]]];嵌套:SearchParseException [无法解析搜索源[{"来自":0,"尺寸":10,"查询":{"匹配&#34 ;:{" title":{" query":" Top Coat"," type":" boolean", "操作":" OR""分析器":" my_analyzer""模糊":" 1& #34;" minimum_should_match":" 95%"}}}}]];嵌套:QueryParsingException [[match] analyzer [my_analyzer] not found]; } {[tdPbTD9IQhSuvkFMYt1WbA] [catalogviews] [1]:RemoteTransportException [[Shellshock] [my_ip:9300] [indices:data / read / search [phase / dfs]]];嵌套:SearchParseException [无法解析搜索源[{"来自":0,"尺寸":10,"查询":{"匹配&#34 ;:{" title":{" query":" Top Coat"," type":" boolean", "操作":" OR""分析器":" my_analyzer""模糊":" 1& #34;" minimum_should_match":" 95%"}}}}]];嵌套:QueryParsingException [[match] analyzer [my_analyzer] not found]; } {[tdPbTD9IQhSuvkFMYt1WbA] [catalogviews] [2]:RemoteTransportException [[Shellshock] [my_ip:9300] [indices:data / read / search [phase / dfs]]];嵌套:SearchParseException [无法解析搜索源[{"来自":0,"尺寸":10,"查询":{"匹配&#34 ;:{" title":{" query":" Top Coat"," type":" boolean", "操作":" OR""分析器":" my_analyzer""模糊":" 1& #34;" minimum_should_match":" 95%"}}}}]];嵌套:QueryParsingException [[match] analyzer [my_analyzer] not found]; } {[tdPbTD9IQhSuvkFMYt1WbA] [catalogviews] [3]:RemoteTransportException [[Shellshock] [my_ip:9300] [indices:data / read / search [phase / dfs]]];嵌套:SearchParseException [无法解析搜索源[{"来自":0,"尺寸":10,"查询":{"匹配&#34 ;:{" title":{" query":" Top Coat"," type":" boolean", "操作":" OR""分析器":" my_analyzer""模糊":" 1& #34;" minimum_should_match":" 95%"}}}}]];嵌套:QueryParsingException [[match] analyzer [my_analyzer] not found]; } {[tdPbTD9IQhSuvkFMYt1WbA] [catalogviews] [4]:RemoteTransportException [[Shellshock] [my_ip:9300] [indices:data / read / search [phase / dfs]]];嵌套:SearchParseException [无法解析搜索源[{"来自":0,"尺寸":10,"查询":{"匹配&#34 ;:{" title":{" query":" Top Coat"," type":" boolean", "操作":" OR""分析器":" my_analyzer""模糊":" 1& #34;" minimum_should_match":" 95%"}}}}]];嵌套:QueryParsingException [[match] analyzer [my_analyzer] not found];根本原因 [catalogviews] QueryParsingException [[match] analyzer [my_analyzer] not found] 在org.elasticsearch.index.query.MatchQueryParser.parse(MatchQueryParser.java:101) 在org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:250) at org.elasticsearch.index.query.IndexQueryParserService.innerParse(IndexQueryParserService.java:320) at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223) at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:218) 在org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33) 在org.elasticsearch.search.SearchService.parseSource(SearchService.java:856) at org.elasticsearch.search.SearchService.createContext(SearchService.java:667) at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633) 在org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:264) at org.elasticsearch.search.action.SearchServiceTransportAction $ SearchDfsTransportHandler.messageReceived(SearchServiceTransportAction.java:360) at org.elasticsearch.search.action.SearchServiceTransportAction $ SearchDfsTransportHandler.messageReceived(SearchServiceTransportAction.java:357) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService $ 4.doRun(TransportService.java:376) 在org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624) 在java.lang.Thread.run(Thread.java:748)
答案 0 :(得分:0)
您必须在所有节点中进行设置。
例如,如果您使用自己的字典设置同义词分析器,则必须将synonym.txt放在所有节点的特定文件夹中。
编辑: 看起来您的映射没问题,请尝试在分析仪中添加“类型”自定义。
"analyzer": {
"spanish": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"spanish_stop",
"spanish_stemmer"
]
}
}
答案 1 :(得分:0)
{"设置":{"分析":{"过滤":{" spanish_stop":{"类型&# 34;:"停止&#34 ;, "停用词":" 西班牙语" }," spanish_stemmer":{" type":" stemmer", "语言":"西班牙语" }," analyzer":{" my_analyzer":{ " tokenizer":"标准","过滤":["小写"," spanish_stop", " spanish_stemmer" ]}},"映射":{" catalogviewparent":{ "属性":{" title":{" type":" string"," analyzer":&#34 ; my_analyzer" }, " fullImageAltDescription":{" type":" string"," analyzer":" my_analyzer" }," name":{" type":" string"," analyzer":" my_analyzer" }}}}}}