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

Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]

這篇具有很好參考價(jià)值的文章主要介紹了Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

項(xiàng)目場(chǎng)景:

Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]

今天在做項(xiàng)目遇到這個(gè)問(wèn)題,Es那邊出現(xiàn)了問(wèn)題,谷粒商城去Es中查數(shù)據(jù)的時(shí)候,根據(jù)品牌id去查詢數(shù)據(jù)報(bào)錯(cuò)。

Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]


Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]?

問(wèn)題描述

{"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: {\n ?\"bool\" : {\n ? ?\"filter\" : [\n ? ? ?{\n ? ? ? ?\"term\" : {\n ? ? ? ? ?\"brandId\" : {\n ? ? ? ? ? ?\"value\" : \"]\",\n ? ? ? ? ? ?\"boost\" : 1.0\n ? ? ? ? ?}\n ? ? ? ?}\n ? ? ?}\n ? ?],\n ? ?\"adjust_pure_negative\" : true,\n ? ?\"boost\" : 1.0\n ?}\n}","index_uuid":"Ihj_ANPsQAOj8Lg3lnCdVA","index":"gulimall_product"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"gulimall_product","node":"lIkiIqcQSwSzRMIbnLDsYA","reason":{"type":"query_shard_exception","reason":"failed to create query: {\n ?\"bool\" : {\n ? ?\"filter\" : [\n ? ? ?{\n ? ? ? ?\"term\" : {\n ? ? ? ? ?\"brandId\" : {\n ? ? ? ? ? ?\"value\" : \"]\",\n ? ? ? ? ? ?\"boost\" : 1.0\n ? ? ? ? ?}\n ? ? ? ?}\n ? ? ?}\n ? ?],\n ? ?\"adjust_pure_negative\" : true,\n ? ?\"boost\" : 1.0\n ?}\n}","index_uuid":"Ihj_ANPsQAOj8Lg3lnCdVA","index":"gulimall_product","caused_by":{"type":"number_format_exception","reason":"For input string: \"]\""}}}]},"status":400}

查詢結(jié)果出現(xiàn)問(wèn)題,查看構(gòu)造語(yǔ)句如下

GET gulimall_product/_search
{
  "from": 0,
  "size": 16,
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "brandId": {
              "value": [
                9
              ],
              "boost": 1
            }
          },
          "terms": {
          "brandId": [
            "1",
            "9"
          ]
        }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "aggregations": {
    "brand_agg": {
      "terms": {
        "field": "brandId",
        "size": 50,
        "min_doc_count": 1,
        "shard_min_doc_count": 0,
        "show_term_doc_count_error": false,
        "order": [
          {
            "_count": "desc"
          },
          {
            "_key": "asc"
          }
        ]
      },
      "aggregations": {
        "brand_name_agg": {
          "terms": {
            "field": "brandName",
            "size": 1,
            "min_doc_count": 1,
            "shard_min_doc_count": 0,
            "show_term_doc_count_error": false,
            "order": [
              {
                "_count": "desc"
              },
              {
                "_key": "asc"
              }
            ]
          }
        },
        "brand_img_agg": {
          "terms": {
            "field": "brandImg",
            "size": 1,
            "min_doc_count": 1,
            "shard_min_doc_count": 0,
            "show_term_doc_count_error": false,
            "order": [
              {
                "_count": "desc"
              },
              {
                "_key": "asc"
              }
            ]
          }
        }
      }
    },
    "catalog_agg": {
      "terms": {
        "field": "catalogId",
        "size": 20,
        "min_doc_count": 1,
        "shard_min_doc_count": 0,
        "show_term_doc_count_error": false,
        "order": [
          {
            "_count": "desc"
          },
          {
            "_key": "asc"
          }
        ]
      },
      "aggregations": {
        "catalog_name_agg": {
          "terms": {
            "field": "catalogName",
            "size": 1,
            "min_doc_count": 1,
            "shard_min_doc_count": 0,
            "show_term_doc_count_error": false,
            "order": [
              {
                "_count": "desc"
              },
              {
                "_key": "asc"
              }
            ]
          }
        }
      }
    },
    "attr_agg": {
      "nested": {
        "path": "attrs"
      },
      "aggregations": {
        "attr_id_agg": {
          "terms": {
            "field": "attrs.attrId",
            "size": 10,
            "min_doc_count": 1,
            "shard_min_doc_count": 0,
            "show_term_doc_count_error": false,
            "order": [
              {
                "_count": "desc"
              },
              {
                "_key": "asc"
              }
            ]
          },
          "aggregations": {
            "attr_name_agg": {
              "terms": {
                "field": "attrs.attrName",
                "size": 1,
                "min_doc_count": 1,
                "shard_min_doc_count": 0,
                "show_term_doc_count_error": false,
                "order": [
                  {
                    "_count": "desc"
                  },
                  {
                    "_key": "asc"
                  }
                ]
              }
            },
            "attr_value_agg": {
              "terms": {
                "field": "attrs.attrValue",
                "size": 50,
                "min_doc_count": 1,
                "shard_min_doc_count": 0,
                "show_term_doc_count_error": false,
                "order": [
                  {
                    "_count": "desc"
                  },
                  {
                    "_key": "asc"
                  }
                ]
              }
            }
          }
        }
      }
    }
  }
}

?


原因分析:

我們可以發(fā)現(xiàn)很明顯是"type":"query_shard_exception","reason":"failed to create query:這里出現(xiàn)了問(wèn)題,也就是構(gòu)造query時(shí)出現(xiàn)了問(wèn)題,意味著在query查詢brandId出現(xiàn)問(wèn)題

單獨(dú)查詢看看

GET /_search
{
  "query": {
    "bool": {
      "filter": {
        "terms": {
          "brandId": [
            "9"
          ]
        }
      }
    }
  }
}

沒問(wèn)題正常返回結(jié)果?,對(duì)比java代碼構(gòu)造的dls語(yǔ)句發(fā)現(xiàn)

"term": {
            "brandId": {
              "value": [
                9
              ],
              "boost": 1
            }

terms寫成了term,說(shuō)明構(gòu)造語(yǔ)句的代碼出現(xiàn)問(wèn)題,查看代碼部分

     if (param.getBrandId()!=null&&param.getBrandId().size()>0){
            boolQuery.filter(QueryBuilders.termQuery("brandId",param.getBrandId()));
        }

不出意外這邊寫的是QueryBuilders.termQuery()而不是QueryBuilders.termsQuery()


解決方案:

注意在這個(gè)地方BrandId為一個(gè)數(shù)組不是一個(gè)值,用term去查詢當(dāng)然會(huì)報(bào)錯(cuò),這也是一個(gè)失誤,排了半個(gè)小時(shí)才排掉,說(shuō)明了對(duì)Es還是不太熟悉對(duì)代碼還是不太熟悉需要加強(qiáng)鞏固

修改java代碼

if (param.getBrandId()!=null&&param.getBrandId().size()>0){
    boolQuery.filter(QueryBuilders.termsQuery("brandId",param.getBrandId()));
}

Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]?

排錯(cuò)成功?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-434591.html

到了這里,關(guān)于Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • elasticsearch中的數(shù)據(jù)類型search_as_you_type及查看底層Lucene索引

    elasticsearch中的數(shù)據(jù)類型search_as_you_type及查看底層Lucene索引

    search_as_you_type字段類型用于自動(dòng)補(bǔ)全,當(dāng)用戶輸入搜索的時(shí)候,還沒輸完就可以提示用戶相關(guān)內(nèi)容。as_you_type應(yīng)該是說(shuō)當(dāng)你打字的時(shí)候。它會(huì)給索引里的這個(gè)類型的字段添加一些子字段_2gram _3gram和_index_prefix。_2gram的意思是,如果一個(gè)值是abcd, 2 gram就是ab bc cd, 3 gram就是

    2024年02月12日
    瀏覽(21)
  • ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=failed t

    今天在用java寫代碼查ES中數(shù)據(jù)的時(shí)候,出現(xiàn)了下面提示的錯(cuò)誤,我排查了一會(huì)才發(fā)現(xiàn)問(wèn)題 ES中地理坐標(biāo)屬性location的數(shù)據(jù)結(jié)構(gòu)是 (緯度,經(jīng)度) ,而我在進(jìn)行字符串拼接的時(shí)候后了中間的逗號(hào),導(dǎo)致插入數(shù)據(jù)錯(cuò)誤。下面就是上面那一段代碼真正有用的部分。 真正錯(cuò)誤原因:

    2024年02月11日
    瀏覽(25)
  • org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=illegal_argument_excep

    org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=illegal_argument_excep

    org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=illegal_argument_exception, reason=request [/zc/_search] contains unrecognized parameters: [ccs_minimize_roundtrips], [ignore_throttled]] 原因: 該異常是由于在對(duì)索引進(jìn)行搜索請(qǐng)求時(shí),使用了不被識(shí)別的參數(shù)導(dǎo)致的。具體來(lái)說(shuō),異常信息中列出了兩

    2024年02月08日
    瀏覽(45)
  • ES排序報(bào)錯(cuò):Elasticsearch exception [type=illegal_argument_exception, reason=Text

    翻譯過(guò)來(lái)就是: 對(duì)于需要每個(gè)文檔字段數(shù)據(jù)(如聚合和排序)的操作,文本字段沒有進(jìn)行優(yōu)化,因此這些操作在默認(rèn)情況下是禁用的。請(qǐng)使用字段代替。或者,在[createTime]上設(shè)置fielddata=true,以便通過(guò)反求倒排索引來(lái)加載字段數(shù)據(jù)。注意,這可能會(huì)使用有效內(nèi)存。] 更改后

    2024年02月11日
    瀏覽(25)
  • Elasticsearch exception [type=index_not_found_exception, reason=no such index [**]]

    Elasticsearch exception [type=index_not_found_exception, reason=no such index [**]]

    ?1.代碼運(yùn)行出現(xiàn)找不到Index,先排除index是否存在。 ? 2.springboot和ES映射,默認(rèn)是把對(duì)象類型映射為index,class對(duì)象默認(rèn)是大寫開頭,所以要看是都是因?yàn)榇笮懖黄ヅ?。如若因?yàn)榇笮懺驅(qū)е?,可以通過(guò)@Document注解指定index ?

    2024年02月14日
    瀏覽(23)
  • Caused by: ElasticsearchException[Elasticsearch exception [type=mapper_parsing_exception, reason=Roo

    Caused by: ElasticsearchException[Elasticsearch exception [type=mapper_parsing_exception, reason=Roo

    ?我們?cè)谑褂肦estClient創(chuàng)建索引庫(kù)時(shí)出現(xiàn)了這個(gè)錯(cuò)誤。 可以檢查一下 CreateIndexRequest 類型變量request 是否導(dǎo)入正確的包 有兩個(gè)同名的包,我們選擇: import org.elasticsearch.client.indices.CreateIndexRequest; ? ? 測(cè)試成功 ?創(chuàng)建的DSL的索引庫(kù) ?以上解決辦法參考 Elasticsearch exception [type=mapp

    2024年01月23日
    瀏覽(25)
  • Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [properties]

    Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [properties]

    Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [properties]: Root mapping definition has unsupported parameters: ? 我們?cè)谑褂肦estClient創(chuàng)建索引庫(kù)時(shí)出現(xiàn)了這個(gè)錯(cuò)誤。 可以檢查一下 CreateIndexRequest 類型變量request 是否導(dǎo)入正確的包 有兩個(gè)同名的包,我們選擇: 創(chuàng)建的索引

    2024年02月11日
    瀏覽(23)
  • 解決Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large問(wèn)題

    解決Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large問(wèn)題

    一、背景 公司有一批8萬(wàn)的數(shù)據(jù)存儲(chǔ)在Mysql中,然后我使用多線程的方式調(diào)用Elasticsearch的bulk()方法推送到ES,但是在推送過(guò)程中出現(xiàn)了該問(wèn)題,這屬于插入數(shù)據(jù)時(shí)產(chǎn)生的問(wèn)題 二、異常 三、解決辦法 加大 -Xms 和 -Xmx 的值,比如 docker-compose.yaml 文件中可以這樣設(shè)置: 四、解釋

    2024年02月03日
    瀏覽(24)
  • Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index r【已解決】

    Elasticsearch exception [type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index r【已解決】

    親測(cè) 2022/08/16 BJ 集群存儲(chǔ)資源高水位異常,默認(rèn)當(dāng)磁盤空間大于95%時(shí),就會(huì)禁止寫入。 首先讓es節(jié)點(diǎn)騰出足夠的空間、 刪除磁盤數(shù)據(jù) ; 擴(kuò)容。 執(zhí)行恢復(fù)命令 讓es恢復(fù)到可寫入狀態(tài)。問(wèn)題解決!

    2024年02月12日
    瀏覽(23)
  • Elasticsearch exception [type=parsing_exception, reason=[multi_match] unknown token [START_ARRAY] af

    代碼報(bào)錯(cuò) QueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(deptIdList, “data.deptId”, “modifiedData.deptId”); multiMatchQuery這個(gè)API,第一個(gè)參數(shù)不支持List類型, 雖然傳List沒報(bào)錯(cuò), 但是往ES發(fā)送查詢請(qǐng)求的時(shí)候就會(huì)拋異常出來(lái) 傳一個(gè)字段, 如果你想多字段in查詢,就用類似下面這樣寫法就可以了

    2024年02月07日
    瀏覽(49)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包