ES检索分组统计异常: ElasticsearchStatusException [Elasticsearch exception [type=illegal_argument_exception

摘要:
异常名称:ElasticsearchStatusException&illegal_ argument_异常异常分析:按品牌字段分组时发生此异常。品牌领域映射是否存在问题?异常原因:当品牌字段初始化时,类型默认为关键字,这会导致分词。在品牌字段上分组时找不到该字段。异常详细信息:ElasticsearchStatusException[Ela

异常名称:ElasticsearchStatusException&illegal_argument_exception

异常分析:按照brand字段进行分组时出现此异常,brand字段mapping出现问题?

异常原因:brand字段初始化时 type 默认为keyword 从而进行了分词,导致在brand字段上做分组时找不到此字段

ES检索分组统计异常: ElasticsearchStatusException [Elasticsearch exception [type=illegal_argument_exception第1张

异常详情:

ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]
]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.]];
    at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
    at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1727)
    at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1704)
    at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1467)
    at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)
    at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
    at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)
    at com.csn.test.EsTest.testAgg(EsTest.java:231)
    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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://localhost:9201], URI [/product/_search?typed_keys=true&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":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"product","node":"7gG1p5NESheE0e0w4KxaLQ","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.","caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."}}},"status":400}
        at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:253)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:231)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:205)
        at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1454)
        ... 28 more
Caused by: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.]];
    at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:491)
    at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:402)
    at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:432)
    at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:598)
    at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:169)
    ... 31 more
Caused by: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [brand] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.]]
    at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:491)
    at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:402)
    at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:432)
    ... 35 more

解决方案:清空index库,重新设定es智能映射模板,将brand字段type设为kyword

PUT /product
{
  "mappings": {
          "properties": {
              "id": {
                  "type": "keyword"
              },
              "title": {
                  "type": "text",
                  "analyzer": "ik_max_word"
              },
              "category": {
                  "type": "keyword"
              },
              "brand": {
                  "type": "keyword"
              },
              "images": {
                  "type": "keyword",
                  "index":  false
              },
              "price": {
                  "type": "double"
              }
          }
  }
}
解决结果:成功

注意事项:对es建index库时一定要确定数据结构,慎重编写映射配置

未经允许 禁止转载

免责声明:文章转载自《ES检索分组统计异常: ElasticsearchStatusException [Elasticsearch exception [type=illegal_argument_exception》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇BSP模型json-bigint的介绍和使用-解决Javascript的有关大整数问题下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

【Java】VS Code导入jar包及进行JUnit单元测试

如何配置 VS Code 下的 Java 开发环境就不细说了,只要安装好了 JDK,安装一个插件 Java Extension Pack 就行了,它会自动安装几个微软推荐的插件,基础的 Java 环境就搭好了。 进行 JUnit 单元测试需要的 jar 包:junit.jar 和 hamcrest-core.jar,链接如下: https://github...

vscode wsl2使用junit测试java

首先你要安装有插件 Java Extension Pack 然后下载两个文件,Junit模块支持需要两个文件:hamcrest&JUnit https://github.com/junit-team/junit4/wiki/Download-and-Install 在当前代码目录下建立文件夹lib,把两个放进去。...

Eclipse开发Maven项目提示:程序包org.junit不存在解决方案

1、产生的问题: maven项目执行单元测试可以正常执行,但是执行maven命令test,则报一下异常: org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile (default-testCompile) on project support: Compilation failure...

12个提高Java程序员工作效率的工具

  Java开发者常常都会想办法如何更快地编写Java代码,让开发过程变得更加轻松,更加高效。目前,市面上涌现出越来越多的高效编程工具。团长总结了几个常用的工具,其中包含了大多数开发人员已经使用、正在使用或将来一定会用到的高效工具。      1、Eclipse   Eclipse是最有名也最广泛使用的Java集成开发环境(IDE),允许开发者结合语言支持...

JUnit —— TestSuite 的使用

首先说一下,suite ,中文是 一套,一组的意思。 那么,TestSuite,顾名思义,就是用来运行一组测试的。 如何使用呢 ? 假设有个这样的测试类StudentDAOTest ,代码如下: 1 packageorg.young.junit.testsuite; 2 3 importjunit.framework.TestCase; 4 5 imp...

java之单元测试

这篇主要简单讲下java的单元测试 目录结构如下: 如图,其中1是需要被测试的功能;2是测试模块;3是单元测试需要的引入包; 1. 功能模块1中 Calculator 的代码: package cn.vincent.calc; public class Calculator { public int add(int a,int b){...