【发布时间】:2018-11-26 10:06:57
【问题描述】:
我正在尝试将值列表传递给QueryBuilders.termsQuery(),但它抛出了错误:
抑制:org.elasticsearch.client.ResponseException:方法 [GET], 主机 [http://localhost:9200], URI [/replacement/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&search_type=query_then_fetch&batched_reduce_size=512], 状态行 [HTTP/1.1 400 错误请求]
这是我的java代码:
Replacement linkId = null;
Replacement replacement = null;
List<Replacement> linkIDList=new ArrayList<Replacement>();
for (SearchHit hit1 : searchHits1) {
linkId = new Replacement();
Map<String, Object> sourceAsMap1 = hit1.getSourceAsMap();
linkId.setLink_id((Integer) sourceAsMap1.get("link_id"));
linkIDList.add(linkId);
}
QueryBuilder qb2 = QueryBuilders.termsQuery("id",linkIDList); // this line throws error
这段代码有什么问题?
请找到完整的堆栈跟踪
Suppressed: org.elasticsearch.client.ResponseException: method [GET], host [http://localhost:9200], URI [/replacement/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&search_type=query_then_fetch&batched_reduce_size=512], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: {\n \"terms\" : {\n \"id\" : [\n \"com.demo.searchengine.bean.Replacement@43262676\",\n \"com.demo.searchengine.bean.Replacement@1c3035bc\",\n \"com.demo.searchengine.bean.Replacement@1ae1b004\",\n \"com.demo.searchengine.bean.Replacement@5ba72360\",\n \"com.demo.searchengine.bean.Replacement@29c0bbf4\",\n \"com.demo.searchengine.bean.Replacement@3440e6a5\"\n ],\n \"boost\" : 1.0\n }\n}","index_uuid":"IivTlnL9QCmEUlisIilYUg","index":"replacement"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"replacement","node":"uPLyU7R5RXeirg8XzRqhnA","reason":{"type":"query_shard_exception","reason":"failed to create query: {\n \"terms\" : {\n \"id\" : [\n \"com.demo.searchengine.bean.Replacement@43262676\",\n \"com.demo.searchengine.bean.Replacement@1c3035bc\",\n \"com.demo.searchengine.bean.Replacement@1ae1b004\",\n \"com.demo.searchengine.bean.Replacement@5ba72360\",\n \"com.demo.searchengine.bean.Replacement@29c0bbf4\",\n \"com.demo.searchengine.bean.Replacement@3440e6a5\"\n ],\n \"boost\" : 1.0\n }\n}","index_uuid":"IivTlnL9QCmEUlisIilYUg","index":"replacement","caused_by":{"type":"number_format_exception","reason":"For input string: \"com.demo.searchengine.bean.Replacement@43262676\""}}}]},"status":400}
【问题讨论】:
-
请打印完整的堆栈跟踪。在此之后必须有剩余的错误跟踪
-
@Richa - 我已经更新了完整的堆栈跟踪。
标签: java elasticsearch collections elastic-stack elasticsearch-java-api