Exception in thread "main" 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 [content_type] 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 [content_type] 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.softsec.util.demoTime.main(demoTime.java:98)
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://192.168.101.92:9200], URI [/news/_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 [content_type] 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":"news","node":"8GuMfo5aRz2CCgl49bY0aQ","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [content_type] 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 [content_type] 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 [content_type] 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)
... 4 more
This is because the string (content_type) type of my grouping aggregate query is of type Text
Reason analysis:
When using term query, the type of the query keyword on ES must be keyword rather than text because it is an accurate match. For example, if your search condition is “name” : “Cai Xukun”, then the ES type of the name field must be keyword rather than text
In es, only the keyword type string can use AggregationBuilders. Terms (” aggs – class “) to group aggregation and grouping want to query, according to the specified keyword attribute of grouping field is ok (below);
How do we change that in our Java code?Below, just add “.keyword”
Add to the previous error:
Read More:
- circuit_breaking_exception,“reason“:“[parent] Data too large, data for [<http_request>]
- Window installation of MongoDB exception: connect failed exception
- Unexplained exception 005: uncaught error: can’t resolve all parameters for applicationmodule
- SystemError: execution of module h5py.utils raised unreported exception
- How to Fix error performing isolated work; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarE
- The solution of a Java exception has occurred. And error exception in thread when eclipse runs
- Realize the simplest recursive call, simulate exception in thread “main” java.lang.stackoverflowerror exception
- Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrup
- Elasticsearch startup process error: org.elasticsearch.transport .BindTransportException: Failed to bind to [9300-9400
- Resolve rabbitmq declarationexception: failed to declare queue exception
- (Solved) pytorch error: RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED (install cuda)
- [Handling Notes] Alternative reasons for Configuration system failed to initialize exception
- The mongoDB service failed to start (exception: connect failed)
- Request processing failed;nested exception is java.lang.*
- keytool error: java.lang.Exception: Failed to establish chain from reply
- IBM MQ Reason 2538(MQRC_ HOST_ NOT_ An example of error reason
- Failed to instantiate org.mybatis.spring.SqlSessionTemplate Constructor threw exception
- Spring boot JPA Repository exception Validation failed for query for method
- Layer loading failed! Exception from HResult: 0x80040228
- [Solved] nested exception is com.alibaba.dubbo.rpc.RpcException: Failed t o invoke the method findPage