Я хочу перевести этот Elasticsearch Query в клиент низкого уровня RestClient.
GET try1\_search
{
"query": {
"match": {
"process.pa_name": "luca"
}
}
}
Мои данные JSON выглядят так,
{
"_index": "try1",
"_type": "_doc",
"_id": "2",
"_score": 1,
"_source": {
"target": {
"br_id": 0,
"an_id": 0,
"ai_id": 0,
"explanation": [
"element 1",
"element 2"
]
},
"process": {
"an_id": 1311,
"pa_name": "micha"
},
"text": "hello world"
}
},
{
"_index": "try1",
"_type": "_doc",
"_id": "1",
"_score": 1,
"_source": {
"target": {
"br_id": 0,
"an_id": 1,
"ai_id": 1,
"explanation": [
"element 3",
"element 4"
]
},
"process": {
"an_id": 1311,
"pa_name": "luca"
},
"text": "the all People are good"
}
}
]
}
}
Я написал что-то вроде этого, используя RestClient вНизкоуровневый клиент, чтобы получить все сущности из данных JSON,
try {
RestClient restClient = RestClient.builder(
new HttpHost("localhost", 9200, "http")).build();
Response response1 = restClient.performRequest("GET", "/try1/_doc/_search?size=" + 10, Collections.singletonMap("pretty", "true"));
String responseBody = EntityUtils.toString(response1.getEntity());
System.out.println("result is : " + responseBody);
} catch (UnknownHostException ex) {
System.out.println("failure : " + ex.getMessage());
}
Может ли кто-нибудь помочь мне расширить мой код, чтобы получить вышеупомянутый Elastic Search Query?Я буду благодарен.