尝试使用带有RestClient API的弹性搜索来查询确切的JSON主体,但是使用hits,_source等将整个主体作为响应进行查询。
所以尝试了filter_path [[filter_path = hits.hits._source]]的方法来解决这个问题,但即便如此,也无法帮助获取精确的正文并带有_source标记,如下面提到的filter_path Response。 / p>
任何人都可以建议请如何获得精确的json身体作为回应 {" testAcct":" 1234" }
Client.java: -
RestClient client = RestClient.builder(
new HttpHost(HOST, 9200, HTTP)).build();
Response response1 = client.performRequest("GET", SERVICE_URL + "_search",
Collections.<String, String>emptyMap(), new BasicHeader("testAcct", "1234"));
System.out.println(EntityUtils.toString(response1.getEntity()));
响应: -
{
"took":6,
"timed_out":false,
"_shards":{
"total":1,
"successful":1,
"failed":0
},
"hits":{
"total":21,
"max_score":1.0,
"hits":[
{
"_index":"testindex",
"_type":"testexternal",
"_id":"AVmHwA7Pkw5MudRUOp-q",
"_score":1.0,
"_source":{
"testAcct":"1234"
}
}
}
]
}
filter_path响应: -
{
"hits":{
"hits":[
{
"_source":{
"testAcct":"1234"
}
}
}
}