我正在尝试查询索引,我已经检查了索引名称。同一段代码在一台机器上完美执行,而在另一台机器上,它给了我这个例外
java.lang.NullPointerException: null
at org.elasticsearch.ElasticsearchException.getIndex(ElasticsearchException.java:1083) ~[elasticsearch-6.4.3.jar!/:6.4.3]
at org.elasticsearch.ElasticsearchException.toString(ElasticsearchException.java:696) ~[elasticsearch-6.4.3.jar!/:6.4.3]
at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_191]
at java.lang.StringBuilder.append(StringBuilder.java:131) ~[na:1.8.0_191]
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:52) ~[spring-core-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.springframework.web.util.NestedServletException.getMessage(NestedServletException.java:82) ~[spring-web-5.1.4.RELEASE.jar!/:5.1.4.RELEASE]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:238) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.14.jar!/:9.0.14]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]
现在我已经检查了以下内容
如果索引不存在,那么我们将得到另一个异常,我无法理解该异常的原因。
编辑1:这是我正在使用的查询
"from": 0,
"size": 6,
"timeout": "1000ms",
"query": {
"bool": {
"must": [
{
"match": {
"searchName": {
"query": "new delh",
"operator": "OR",
"analyzer": "standard",
"fuzziness": "1",
"prefix_length": 8,
"max_expansions": 200,
"minimum_should_match": "100%",
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1
}
}
}
],
"filter": [
{
"term": {
"isSearchEnabled": {
"value": true,
"boost": 1
}
}
}
],
"should": [
{
"match": {
"searchName": {
"query": "new delh",
"operator": "OR",
"analyzer": "standard",
"fuzziness": "2",
"prefix_length": 1,
"max_expansions": 200,
"minimum_should_match": "100%",
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"sort": [
{
"entityDisplayOrder": {
"order": "asc"
}
},
{
"propertyCount": {
"order": "desc"
}
}
]