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

ES排序報(bào)錯(cuò):Elasticsearch exception [type=illegal_argument_exception, reason=Text

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

更改前:

@ApiOperation("分頁(yè)排序")
    @GetMapping("pageAndSort/{page}/{size}")
    public Page<Hero> pageAndSort(@PathVariable Integer page,@PathVariable Integer size){
        //構(gòu)建本地查詢(xún)對(duì)象
        NativeSearchQueryBuilder query = new NativeSearchQueryBuilder();
        //
        PageRequest pageRequest = PageRequest.of(page, size);

        query.withPageable(pageRequest);
        query.withSort(SortBuilders.fieldSort("createTime").order(SortOrder.DESC));

        SearchHits<Hero> search = elasticTemplate.search(query.build(), Hero.class);
        List<Hero> blogs = new ArrayList<>();
        for (SearchHit<Hero> hero : search) {
            blogs.add(hero.getContent());
        }
        PageImpl<Hero> heroes = new PageImpl<>(blogs, pageRequest, search.getTotalHits());
        return heroes;
    }

錯(cuò)誤提示信息:Elasticsearch exception [type=illegal_argument_exception, reason=Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [createTime] in order to load field data by uninverting the inverted index. Note that this can use significant memory.]

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

在es中,text類(lèi)型的字段使用一種叫做fielddata的查詢(xún)時(shí)內(nèi)存數(shù)據(jù)結(jié)構(gòu)。當(dāng)字段被排序,聚合或者通過(guò)腳本訪(fǎng)問(wèn)時(shí)這種數(shù)據(jù)結(jié)構(gòu)會(huì)被創(chuàng)建。它是通過(guò)從磁盤(pán)讀取每個(gè)段的整個(gè)反向索引來(lái)構(gòu)建的,然后存存儲(chǔ)在java的堆內(nèi)存中。

 這里fileddata默認(rèn)是不開(kāi)啟的。Fielddata可能會(huì)消耗大量的堆空間

所以換一種方式解決:在需要的字段上添加關(guān)鍵字? keyword

更改后:

 @ApiOperation("分頁(yè)排序")
    @GetMapping("pageAndSort/{page}/{size}")
    public Page<Hero> pageAndSort(@PathVariable Integer page,@PathVariable Integer size){
        //構(gòu)建本地查詢(xún)對(duì)象
        NativeSearchQueryBuilder query = new NativeSearchQueryBuilder();
        //
        PageRequest pageRequest = PageRequest.of(page, size);

        query.withPageable(pageRequest);
        query.withSort(SortBuilders.fieldSort("createTime.keyword").order(SortOrder.DESC));

        SearchHits<Hero> search = elasticTemplate.search(query.build(), Hero.class);
        List<Hero> blogs = new ArrayList<>();
        for (SearchHit<Hero> hero : search) {
            blogs.add(hero.getContent());
        }
        PageImpl<Hero> heroes = new PageImpl<>(blogs, pageRequest, search.getTotalHits());
        return heroes;
    }


? ? ? ? query.withSort(SortBuilders.fieldSort("createTime.keyword").order(SortOrder.DESC));文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-506932.html

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

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(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)文章

  • 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日
    瀏覽(46)
  • 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ì)象類(lèi)型映射為index,class對(duì)象默認(rèn)是大寫(xiě)開(kāi)頭,所以要看是都是因?yàn)榇笮?xiě)不匹配。如若因?yàn)榇笮?xiě)原因?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 類(lèi)型變量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=search_phase_execution_exception, reason=all shards failed]

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

    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去查詢(xún)數(shù)據(jù)報(bào)錯(cuò)。 ? {\\\"error\\\":{\\\"root_cause\\\":[{ \\\"type\\\":\\\"query_shard_exception\\\",\\\"reason\\\":\\\"failed to create query: {n ?\\\"bool\\\" : {n ? ?\\\"fil

    2024年02月02日
    瀏覽(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中,然后我使用多線(xiàn)程的方式調(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日
    瀏覽(26)
  • 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 類(lèi)型變量request 是否導(dǎo)入正確的包 有兩個(gè)同名的包,我們選擇: 創(chuàng)建的索引

    2024年02月11日
    瀏覽(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)磁盤(pán)空間大于95%時(shí),就會(huì)禁止寫(xiě)入。 首先讓es節(jié)點(diǎn)騰出足夠的空間、 刪除磁盤(pán)數(shù)據(jù) ; 擴(kuò)容。 執(zhí)行恢復(fù)命令 讓es恢復(fù)到可寫(xiě)入狀態(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類(lèi)型, 雖然傳List沒(méi)報(bào)錯(cuò), 但是往ES發(fā)送查詢(xún)請(qǐng)求的時(shí)候就會(huì)拋異常出來(lái) 傳一個(gè)字段, 如果你想多字段in查詢(xún),就用類(lèi)似下面這樣寫(xiě)法就可以了

    2024年02月07日
    瀏覽(49)
  • ES 報(bào)錯(cuò) 403 cluster_block_exception....

    錯(cuò)誤日志如上,導(dǎo)致報(bào)錯(cuò)的原因是 索引變?yōu)橹蛔x,因?yàn)榇疟P(pán)上沒(méi)有更多空間。如果您使用了 95% 的磁盤(pán)空間。es 服務(wù)器將每 30 秒將所有索引變?yōu)橹蛔x模式。如果沒(méi)有剩余空間,則需要釋放足夠的空間或按照指南所述更改 es 配置。 解決思路 1.清理或者擴(kuò)展磁盤(pán)空間 2.es服務(wù)器

    2024年02月11日
    瀏覽(21)
  • elasticsearch創(chuàng)建索引報(bào)[type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]......

    elasticsearch創(chuàng)建索引報(bào)[type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]......

    小伙伴們,你們好,我是老寇 經(jīng)過(guò)反復(fù)排查,發(fā)現(xiàn)是安裝的pinyin和ik分詞版本不對(duì),只需要修改成與es版本一致即可 es 7.6.2 舉例 1.在windows界面用壓縮軟件打開(kāi)elasticsearch-analysis-ik-7.6.2.jar 2.將pom.xml拖出到桌面 3.修改版本 4.將pom.xml放回壓縮包( 原路放回 ) 5. elasticsearch-analysis

    2024年02月13日
    瀏覽(28)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包