uptasticsearch icon indicating copy to clipboard operation
uptasticsearch copied to clipboard

How to enter API key to connect to elastic instance

Open sebastiz opened this issue 3 years ago • 1 comments

I wanted to use your packed to connect but I'm not sure which parameters to use within the connect function especially to include the API key with the headers etc I am using in the httr::GET request below

At the moment Im trying to search with httr using code similar to this:

library(httr) library(RJSONIO) library(curl)

my_query <- rjson::toJSON( '{ "query": { "match" : { "LastName": "MyName" } } }' )

get_scroll_id <- httr::GET( url = "https://MyServer:9200/MyIndex/_search", query = list(scroll = "1m", size = "10000"), encoding = 'json', httr::add_headers( .headers = c( "Authorization" = "ApiKey ****", "Content-Type" = "application/json" ) ), config=httr::config(ssl_verifypeer = FALSE,ssl_verifyhost = FALSE), body = my_query )

scroll_data <- fromJSON(content(get_scroll_id, as="text"))

This returns data but doesn't let me run a query for reasons I don't understand. Hence why I wanted to use your package. Thanks in advance

sebastiz avatar May 26 '21 17:05 sebastiz

Thanks for using {uptasticsearch}!

doesn't let me run a query for reasons I don't understand

Can you provide any logs or error messages that could help us to understand more specifically what is happening? There are many different situations which could be described as "doesn't let me run a query".

jameslamb avatar May 26 '21 18:05 jameslamb