X-pack security using java code

We are creating restclient for connection elastic server, and using HTTPentity for fetching data using index name
check below code

RestClient restClient = RestClient.builder(new HttpHost(Constents.ELK_URL, Constents.ELK_PORT, "http")).build();

HttpEntity entity = null;
entity = new NStringEntity(
"{ \n"+
""query": { \n"+
""bool": { \n"+
""must": [ \n"+
" { \n"+

					            "\"match\": { \n"+
					             
					              "\"bank_client_entity_name.keyword\": { \n"+
					               " \"query\": \""+bankClientEntityName+"\" \n"+
					              "} \n"+
					              "} \n"+
					          "} \n"+
					        "] \n"+
					      "} \n"+
					      "}, \n"+
					      
						 "\"sort\": [ \n"+
						"{ \n"+
						"\"timeperiod_id\": {\"order\" : \"desc\"}, \n"+
						"\"date_status\": {\"order\" : \"desc\"} \n"+
						"} \n"+
						"], \n"+
						" \"size\" : 1 \n"+
					"}", ContentType.APPLICATION_JSON);

Response response = restClient.performRequest("GET", "/"+eLK_HIST_INDEX+"/_search",Collections.<String, String>emptyMap(),entity);
BufferedInputStream br = new BufferedInputStream(response.getEntity().getContent());

please tell me how to add security X-pack in this above code

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Here we go: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_basic_authentication.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.