gpt4 book ai didi

elasticsearch - java.lang.IllegalArgumentException : cannot write xcontent for unknown value of type class java. util.UUID?

转载 作者:行者123 更新时间:2023-12-02 22:14:21 24 4
gpt4 key购买 nike

嗨,我正在使用 java 高级 rest api 客户端从 Elasticsearch 索引中读取一些文档,但出现以下错误。

当我在 elasticsearch 客户端上执行请求时出现此错误,如下所示。

elasticSearchClient.search(searchRequest, RequestOptions.DEFAULT);

java.lang.IllegalArgumentException: cannot write xcontent for unknown value of type class java.util.UUID
at org.elasticsearch.common.xcontent.XContentBuilder.unknownValue(XContentBuilder.java:833)
at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:804)
at org.elasticsearch.common.xcontent.XContentBuilder.field(XContentBuilder.java:789)
at org.elasticsearch.index.query.MatchQueryBuilder.doXContent(MatchQueryBuilder.java:371)
at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:88)
at org.elasticsearch.index.query.BoolQueryBuilder.doXArrayContent(BoolQueryBuilder.java:280)
at org.elasticsearch.index.query.BoolQueryBuilder.doXContent(BoolQueryBuilder.java:261)
at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:88)
at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:857)
at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:850)
at org.elasticsearch.common.xcontent.XContentBuilder.field(XContentBuilder.java:842)
at org.elasticsearch.search.builder.SearchSourceBuilder.innerToXContent(SearchSourceBuilder.java:1182)
at org.elasticsearch.search.builder.SearchSourceBuilder.toXContent(SearchSourceBuilder.java:1309)
at org.elasticsearch.common.xcontent.XContentHelper.toXContent(XContentHelper.java:353)

以下是我的 Elasticsearch 索引的内容。
curl -X GET "localhost:9200/mep-report-today/_search/?size=10"
{"took":9,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":100,"max_score":1.0,"hits":[{"_index":"mep-report-today","_type":"doc","_id":"k33fEW0B6qRb3bOs9s4M","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"lH3fEW0B6qRb3bOs9s4M","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"n33fEW0B6qRb3bOs9s4M","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"oH3fEW0B6qRb3bOs9s4M","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"oX3fEW0B6qRb3bOs9s4M","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"on3fEW0B6qRb3bOs9s4N","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"pH3fEW0B6qRb3bOs9s4N","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"rn3fEW0B6qRb3bOs9s4N","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"t33fEW0B6qRb3bOs9s4N","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}},{"_index":"mep-report-today","_type":"doc","_id":"wX3fEW0B6qRb3bOs9s4N","_score":1.0,"_source":{"inventory":"SMS","msg_text":"This is random text","status":"ENROUTE","@timestamp":"2019-09-02T09:48:09.213Z","o_error":"","flight_id":"92348fa1-ca6c-456a-b3b2-85fba2d2deed","recipient":"420736408283","account_id":"a56f7e14-20f9-40e6-90c6-10604140ac5f","sender":"8800111","campaign_id":"6f2abca3-b46d-43f3-91be-3278a8dd7dc0","nof_segments":1,"@version":1,"submission_ts":1567681407000,"delivery_ts":1549246209000}}]}}

知道这个错误的原因是什么。
我正在使用 Elasticsearch java rest 客户端 api 版本 6.6.1

非常感谢任何帮助
谢谢你

最佳答案

我已经使用 toString() 来解决这个问题, messageHistoryFilterRequest.getAccountId() 正在返回一个 java.util.UUID 。 Elasticsearch 不理解 UUID 。所以一旦我做了一个 toString() 就解决了

if (messageHistoryFilterRequest.getAccountId() != null) {
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("account_id",
messageHistoryFilterRequest.getAccountId().toString());
boolQueryBuilder.must(matchQueryBuilder);
}

if (messageHistoryFilterRequest.getCampaignId() != null) {
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("campaign_id",
messageHistoryFilterRequest.getCampaignId().toString());
boolQueryBuilder.must(matchQueryBuilder);
}

if (messageHistoryFilterRequest.getFlightId() != null) {
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("flight_id",
messageHistoryFilterRequest.getFlightId().toString());
boolQueryBuilder.must(matchQueryBuilder);
}

关于elasticsearch - java.lang.IllegalArgumentException : cannot write xcontent for unknown value of type class java. util.UUID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57850398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com