ticofab
ticofab

Reputation: 7717

AWS ElasticSearchService - Java SDK example?

I am using the ElasticsearchService from Amazon. I am a little overwhelmed by their documentation. I find it vast but ever so difficult to navigate. Anyway, I am looking for an example of using the ESService using their AWS Java SDK. Do you have a link - or some code to insert a document?

I am actually using it from Scala, and what I've got so far is:

val awsEsClient: AWSElasticsearchClient = new AWSElasticsearchClient()
awsEsClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1))
awsEsClient.setEndpoint("es.eu-central-1.amazon.aws.com")
val createD = new CreateElasticsearchDomainRequest()

Where should I specify my own instance ARN? The uri that looks like

arn:aws:es:eu-central-1:xxxxxxxxxxx:domain/yyyyyyyy

Also, when using their SDK, I guess I don't need to specify anywhere the endpoint they provide? The one that goes by

search-yyyyyy-xxxxxxxxxx.eu-central-1.es.amazonaws.com

Or maybe this is what I should specify instead of the

awsEsClient.setEndpoint("es.eu-central-1.amazon.aws.com")

Thank you for your help and sorry if all these questions sound obvious.

Upvotes: 1

Views: 968

Answers (1)

ticofab
ticofab

Reputation: 7717

So, I got the whole thing wrong from the beginning. The SDK is useful only in order to manage the service, like spin up new nodes and similar -- not to access it. For that, the only solution that Amazon offers is an HTTP endpoint, using the common REST api offered by Elastic Search. The problem that came next was to authenticate the requests. I have compiled a scala library to do that for every request, which is available here: https://github.com/ticofab/aws-request-signer.

Upvotes: 4

Related Questions