bcuff / elasticsearch-net-aws

Add-on to Elasticsearch.Net & NEST for using AWS's elasticsearch service.
Apache License 2.0
72 stars 27 forks source link

Connection examples don't seem to work. #8

Closed tveyes-user closed 8 years ago

tveyes-user commented 8 years ago

Hello,

I'm trying to work out how to use this library to connect to Elastic Search running on Amazon's hosted AWS offering. However, it seems like that changes in Elasticsearch.Net have broken this example.

I'm using Elasticsearch.Net.Aws from Git, and I'm using ElasticSearch.Net 2.0.0.0 installed via NuGet.

Here's my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Elasticsearch.Net;
using Elasticsearch.Net.Aws;

namespace AWSConnectionTests
{
    class Program
    {
        static void Main(string[] args)
        {
            var httpConnection = new AwsHttpConnection(new AwsSettings
            {
                AccessKey = "My AWS access key",
                SecretKey = "My AWS secret key",
                Region = "us-east-1",
            });

            var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
            var config = new ConnectionSettings(pool, httpConnection);
            var client = new ElasticClient(config);
        }
    }
}

I'm getting the following type errors:

Has something changed? Am I tilting and windmills?

Thanks!

-D

bcuff commented 8 years ago

Sorry, the example is using the high-level NEST client. If you install the NEST package and add the right namespaces it should work. I'll try and update the examples to make that more clear in the future.

tveyes-user commented 8 years ago

Thanks for the quick response!

When using Nest, does Elasticsearch.Net.Aws still require Elasticsearch.Net?

Thanks!

-D

bcuff commented 8 years ago

Yes. But Nest also requires Elasticsearch.Net. It's part of the same project.

tveyes-user commented 8 years ago

One last question:

At what point do you use the Amazon-provided URL for the service.

            var httpConnection = new AwsHttpConnection(new AwsSettings
            {
                AccessKey = "My AWS access key",
                SecretKey = "My AWS secret key",
                Region = "us-east-1",
            });

            var pool = new SingleNodeConnectionPool(new Uri("http://my-search-url.us-east-1.es.amazonaws.com"));
            var config = new ConnectionSettings(pool, httpConnection);
            var client = new ElasticClient(config);
        }

Is SingleNodeConnectionPool the correct place to configure the actual service endpoint?

Many thanks!

-D

bcuff commented 8 years ago

Yes. That's it.

tveyes-user commented 8 years ago

Many thanks!