ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed t

这篇具有很好参考价值的文章主要介绍了ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed t。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

项目场景:

今天在用java写代码查ES中数据的时候,出现了下面提示的错误,我排查了一会才发现问题


控制台提示

ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed to parse field [location] of type [geo_point]]
]; nested: ElasticsearchException[Elasticsearch exception [type=parse_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]];
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:176)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2011)
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1988)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1745)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1702)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1672)
	at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:1029)
	at com.woniu.EsDemoApplicationTests.insertDoc(EsDemoApplicationTests.java:115)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at 
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
	Suppressed: org.elasticsearch.client.ResponseException: method [PUT], host [http://120.48.46.177:9200], URI [/hotel/_doc/45870?timeout=1m], status line [HTTP/1.1 400 Bad Request]
Warnings: [Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.16/security-minimal-setup.html to enable security.]
{"error":{"root_cause":[{"type":"parse_exception","reason":"unsupported symbol [.] in geohash [30.871729121.81959]"}],"type":"mapper_parsing_exception","reason":"failed to parse field [location] of type [geo_point]","caused_by":{"type":"parse_exception","reason":"unsupported symbol [.] in geohash [30.871729121.81959]","caused_by":{"type":"illegal_argument_exception","reason":"unsupported symbol [.] in geohash [30.871729121.81959]"}}},"status":400}
		at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:326)
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:296)
		at org.elasticsearch.client.RestClient.performRequest(RestClient.java:270)
		at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2082)
		at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1732)
		... 71 more
Caused by: ElasticsearchException[Elasticsearch exception [type=parse_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]];
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:485)
	at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:396)
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:426)
	at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:592)
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:168)
	... 74 more
Caused by: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=unsupported symbol [.] in geohash [30.871729121.81959]]]
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:485)
	at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:396)
	at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:426)

原因分析:

ES中地理坐标属性location的数据结构是(纬度,经度),而我在进行字符串拼接的时候后了中间的逗号,导致插入数据错误。下面就是上面那一段代码真正有用的部分。

真正错误原因:

{"error":{"root_cause":[{"type":"parse_exception","reason":"unsupported symbol [.] in 
geohash [30.871729121.81959]"}],"type":"mapper_parsing_exception","reason":"failed to parse 
field [location] of type [geo_point]","caused_by":{"type":"parse_exception","reason":"unsupported symbol [.] in geohash 
[30.871729121.81959]","caused_by":
{"type":"illegal_argument_exception","reason":"unsupported symbol [.] in geohash 
[30.871729121.81959]"}}},"status":400}

错误写法:

this.location = hotel.getLatitude()+hotel.getLongitude();

正确写法: 

this.location = hotel.getLatitude()+","+hotel.getLongitude();

解决方案:

字符串拼接前要多检查,并且(纬度,经度)这个顺序不能颠倒,不然可能会导致地理位置错误。文章来源地址https://www.toymoban.com/news/detail-505185.html

到了这里,关于ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed t的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • elasticsearch创建索引报[type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]......

    小伙伴们,你们好,我是老寇 经过反复排查,发现是安装的pinyin和ik分词版本不对,只需要修改成与es版本一致即可 es 7.6.2 举例 1.在windows界面用压缩软件打开elasticsearch-analysis-ik-7.6.2.jar 2.将pom.xml拖出到桌面 3.修改版本 4.将pom.xml放回压缩包( 原路放回 ) 5. elasticsearch-analysis

    2024年02月13日
    浏览(23)
  • ElasticSearch创建索引报错:mapper_parsing_exception Root mapping definition has unsupported parameters

    ElasticSearch版本号:5.6.14,这个错误和ES版本有一定的关系,还是先交代下版本号,免得有的读者根据我的方法操作后无效 错误翻译: mapper_parsing_exception :映射解析异常 Root mapping definition has unsupported parameters :根映射定义包含不受支持的参数 错误映射语句1: 错误映射语句

    2024年02月11日
    浏览(43)
  • ES内存问题 Elasticsearch exception type=circuit_breaking_exception,

    Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large, data for [http_request] would be [986856200/941.1mb], which is larger than the limit of [986061209/940.3mb], real usage: [986855776/941.1mb], new bytes reserved: [424/424b], usages [request=0/0b, fielddata=2884/2.8kb, in_flight_requests=424/424b, model_inference=0/0b, a

    2023年04月08日
    浏览(40)
  • ES排序报错:Elasticsearch exception [type=illegal_argument_exception, reason=Text

    翻译过来就是: 对于需要每个文档字段数据(如聚合和排序)的操作,文本字段没有进行优化,因此这些操作在默认情况下是禁用的。请使用字段代替。或者,在[createTime]上设置fielddata=true,以便通过反求倒排索引来加载字段数据。注意,这可能会使用有效内存。] 更改后

    2024年02月11日
    浏览(60)
  • Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]

    Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed] 今天在做项目遇到这个问题,Es那边出现了问题,谷粒商城去Es中查数据的时候,根据品牌id去查询数据报错。   {\\\"error\\\":{\\\"root_cause\\\":[{ \\\"type\\\":\\\"query_shard_exception\\\",\\\"reason\\\":\\\"failed to create query: {n  \\\"bool\\\" : {n    \\\"fil

    2024年02月02日
    浏览(31)
  • Elasticsearch exception [type=index_not_found_exception, reason=no such index [**]]

     1.代码运行出现找不到Index,先排除index是否存在。   2.springboot和ES映射,默认是把对象类型映射为index,class对象默认是大写开头,所以要看是都是因为大小写不匹配。如若因为大小写原因导致,可以通过@Document注解指定index  

    2024年02月14日
    浏览(32)
  • 解决Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large问题

    一、背景 公司有一批8万的数据存储在Mysql中,然后我使用多线程的方式调用Elasticsearch的bulk()方法推送到ES,但是在推送过程中出现了该问题,这属于插入数据时产生的问题 二、异常 三、解决办法 加大 -Xms 和 -Xmx 的值,比如 docker-compose.yaml 文件中可以这样设置: 四、解释

    2024年02月03日
    浏览(37)
  • Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index r【已解决】

    亲测 2022/08/16 BJ 集群存储资源高水位异常,默认当磁盘空间大于95%时,就会禁止写入。 首先让es节点腾出足够的空间、 删除磁盘数据 ; 扩容。 执行恢复命令 让es恢复到可写入状态。问题解决!

    2024年02月12日
    浏览(32)
  • Elasticsearch exception [type=parsing_exception, reason=[multi_match] unknown token [START_ARRAY] af

    代码报错 QueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(deptIdList, “data.deptId”, “modifiedData.deptId”); multiMatchQuery这个API,第一个参数不支持List类型, 虽然传List没报错, 但是往ES发送查询请求的时候就会抛异常出来 传一个字段, 如果你想多字段in查询,就用类似下面这样写法就可以了

    2024年02月07日
    浏览(41)
  • ARMv8-AArch64 的异常处理模型详解之异常类型 Exception types

    异常(Exception)通俗点来讲,就是系统在正常运行的时候出现的非正常事件,这个非正常事件会导致系统状态更改或者其他错误,为了确保系统功能能正常运行,需要一些带有特权的软件代码(exception handler)来采取一些补救措施或者更新系统状态,这个过程被称为异常处理

    2024年01月21日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包