国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

elasticsearch 7.12.1報錯處理:ElasticsearchStatusException[Elasticsearch exception [type=parse_exception]

這篇具有很好參考價值的文章主要介紹了elasticsearch 7.12.1報錯處理:ElasticsearchStatusException[Elasticsearch exception [type=parse_exception]。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔


前言

最近在使用RestHighLevelClient測試后端數(shù)據(jù)時,遇到如下一個報錯:


ElasticsearchStatusException[Elasticsearch exception [type=parse_exception, reason=numeric value expected]
]
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:176)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1933)
	...
	Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://192.***.***.***:9200], URI [/exp_store_location/_search?typed_keys=true&max_concurrent_shard_requests=5&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&search_type=query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"parse_exception","reason":"numeric value expected"}],"type":"parse_exception","reason":"numeric value expected"},"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.internalPerformRequest(RestHighLevelClient.java:1654)
		... 71 more

一、我的測試代碼:

// 根據(jù)坐標排序
    @Test
    void testByLocation() throws Exception {
        SearchRequest request = new SearchRequest("exp_store_location");
        String location = "22.910906957435557,113.87965738641294";
        GeoDistanceQueryBuilder geoDistanceQuery = QueryBuilders.geoDistanceQuery("location"); // 設(shè)置查詢字段
        //geoDistanceQuery.point(new GeoPoint(location)); // 設(shè)置查詢中心坐標
        geoDistanceQuery.distance("15",DistanceUnit.KILOMETERS); // 設(shè)置查詢半徑

        request.source().query(geoDistanceQuery);
        /*request.source().query(QueryBuilders.geoDistanceQuery("location").point(new GeoPoint(location)).distance("15",DistanceUnit.KILOMETERS)).sort(
                SortBuilders
                        .geoDistanceSort("location",new GeoPoint(location))
                        .order(SortOrder.ASC)
                        .unit(DistanceUnit.KILOMETERS)
        ).sort(SortBuilders
                .fieldSort("averagePrice")
                .order(SortOrder.ASC)
        );*/
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        System.out.println(response.toString());
    }

二、問題所在

問題出在我沒有給geoDistanceQuery設(shè)置中心坐標

 		GeoDistanceQueryBuilder geoDistanceQuery = QueryBuilders.geoDistanceQuery("location"); // 設(shè)置搜索字段
        geoDistanceQuery.point(new GeoPoint(location)); // 設(shè)置中心坐標
        geoDistanceQuery.distance("15",DistanceUnit.KILOMETERS); // 設(shè)置搜索距離范圍

設(shè)置中心坐標后問題得到解決。
以下是elastic客戶端查詢索引的代碼文章來源地址http://www.zghlxwxcb.cn/news/detail-593140.html

GET /exp_store_location/_search
{
  "query": {
    "geo_distance": {
      "distance": "150km",
      "location": "22.910906957435557,113.87965738641294"
    }
  }
  , "sort": [
    {
      "_geo_distance": {
        "location": "22.910906957435557,113.87965738641294",
        "order": "asc",
        "unit": "km"
      },
      "averagePrice": {
        "order": "asc"
      }
    }
  ]
}

最后分享一下我自己的范圍測試查詢代碼

 // 根據(jù)坐標排序
    @Test
    void testByLocation() throws Exception {
        SearchRequest request = new SearchRequest("exp_store_location");
        String location = "22.910906957435557,113.87965738641294";
        /*GeoDistanceQueryBuilder geoDistanceQuery = QueryBuilders.geoDistanceQuery("location"); // 設(shè)置查詢字段
        geoDistanceQuery.point(new GeoPoint(location)); // 設(shè)置查詢中心坐標
        geoDistanceQuery.distance("15",DistanceUnit.KILOMETERS); // 設(shè)置查詢半徑
        request.source().query(geoDistanceQuery);*/
        request.source()
                 // 查詢條件
                .query(QueryBuilders.geoDistanceQuery("location")
                        .point(new GeoPoint(location))
                        .distance("15",DistanceUnit.KILOMETERS)
                )
                // 對結(jié)果的排序方式
                .sort(SortBuilders
                        .geoDistanceSort("location",new GeoPoint(location))
                        .order(SortOrder.ASC)
                        .unit(DistanceUnit.KILOMETERS)
                )
                .sort(SortBuilders
                .fieldSort("averagePrice")
                .order(SortOrder.ASC)
                );
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        System.out.println(response.toString());
    }

到了這里,關(guān)于elasticsearch 7.12.1報錯處理:ElasticsearchStatusException[Elasticsearch exception [type=parse_exception]的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Elasticsearch集群索引寫入失敗[FORBIDDEN/12/index read-only / allow delete (api)]處理流程

    操作系統(tǒng):CentOS 7.3 軟件版本:elasticsearch-6.7.2 正常將數(shù)據(jù)寫入到Elasticsearch時,發(fā)現(xiàn)寫入失敗,出現(xiàn)如下報錯 檢查Elasticsearch集群的active master節(jié)點的日志,并沒有發(fā)現(xiàn)error,但有WARN告警,顯示與 flood stage disk watermark [90%] 有關(guān)。 上下文有 low disk watermark [80%] 的INFO日志信息,再次

    2024年02月10日
    瀏覽(22)
  • Elasticsearch8 - Docker安裝Elasticsearch8.12.2

    Elasticsearch8 - Docker安裝Elasticsearch8.12.2

    最近在學(xué)習(xí) ES,所以需要在服務(wù)器上裝一個單節(jié)點的 ES 服務(wù)器環(huán)境:centos 7.9 目前最新版本是 8.12.2 新增配置文件 elasticsearch.yml 解釋一下,前三行是開啟遠程訪問和跨域,最后一行是開啟密碼訪問 Networking | Elasticsearch Guide [8.12] | Elastic 在宿主機創(chuàng)建容器的掛載目錄,我的目錄

    2024年04月15日
    瀏覽(31)
  • Elasticsearch:如何創(chuàng)建 Elasticsearch PEM 和/或 P12 證書?

    Elasticsearch:如何創(chuàng)建 Elasticsearch PEM 和/或 P12 證書?

    你是否希望使用 SSL/TLS 證書來保護你的 Elasticsearch 部署? 在本文中,我們將指導(dǎo)你完成為 Elasticsearch 創(chuàng)建 PEM 和 P12 證書的過程。 這些證書在建立安全連接和確保 Elasticsearch 集群的完整性方面發(fā)揮著至關(guān)重要的作用。 友情提示:你可以選擇其中一種方法來在你的環(huán)境中創(chuàng)建和

    2024年02月13日
    瀏覽(20)
  • 安裝Elasticsearch 8.12.2版本出現(xiàn)的問題

    安裝Elasticsearch 8.12.2版本出現(xiàn)的問題

    ????????在Elasticsearch?官網(wǎng)下載了一個es的安裝包,準備放在windows電腦上研究研究,下載下來之后啟動報錯。 jdk版本對應(yīng) warning: ignoring JAVA_HOME=E:devjdkjdk17jdk-17.0.10; using bundled JDK Exception in thread \\\"main\\\" java.lang.RuntimeException: starting java failed with [1] output: # # There is insufficient

    2024年03月26日
    瀏覽(24)
  • 【異?!縀S報錯ElasticsearchStatusException:missing authentication credentials for REST request

    使用Flink輸出(sink)到Elasticsearch時,出現(xiàn)了上面的錯誤,是因為登錄到ES,ES啟用了賬號密碼的模式,因此必須要使用賬號密碼才能夠訪問它。 于是新增如下代碼后,問題解決

    2024年02月11日
    瀏覽(28)
  • [Spring Boot]12 ElasticSearch實現(xiàn)分詞搜索功能

    [Spring Boot]12 ElasticSearch實現(xiàn)分詞搜索功能

    我們在使用搜索功能的時候,有時,為了使搜索的結(jié)果更多更廣,比如搜索字符串“領(lǐng)導(dǎo)力”,希望有這些組合的結(jié)果(領(lǐng)導(dǎo)力、領(lǐng)導(dǎo)、領(lǐng)、導(dǎo)、力)都要能夠全部展示出來。 這里我們引入ElasticSearch結(jié)合分詞插件,來實現(xiàn)這樣的搜索功能。 比如:一款app需要對“課程”進行

    2024年02月03日
    瀏覽(21)
  • 【Elasticsearch教程12】Mapping字段類型之object

    首先給出結(jié)論: 在一個字段存儲 一個 JSON對象,可以選擇 object 類型 在一個字段存儲 多個 JSON對象,可以選擇 nested 類型 假設(shè)有一個人員信息如下: 建表時會建一個字段存一個值,它的缺點是字段 扁平化 , 無法直觀的表現(xiàn) 層級關(guān)系 。 字段 值 region US manager_age 30 manager_firstn

    2024年02月09日
    瀏覽(20)
  • centos7 搭建Elasticsearch 8.12.2集群并安裝kibana 8.12.2

    rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch vim /etc/yum.repos.d/elasticsearch.repo 輸入以下內(nèi)容(默認會下載最新版本的Elasticsearch):

    2024年03月20日
    瀏覽(27)
  • ElasticSearch_12_ES的高性能設(shè)計

    ElasticSearch_12_ES的高性能設(shè)計

    容量問題: 電商網(wǎng)站商品上億條時,涉及到單表數(shù)據(jù)過大必須拆分表,數(shù)據(jù)庫磁盤占用過大必須分庫(mycat)。 性能問題: mysql實現(xiàn)模糊查詢必須使用 like, 只有 后模糊 才能走索引,前模糊和全模糊都不會走索引,比如查詢“筆記本電腦”等時,上億條數(shù)據(jù)的商

    2024年02月02日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包