NEST2 initialization on .NET C# WebAPI

﹥>﹥吖頭↗ 提交于 2019-12-25 03:59:27

问题


I defined the NEST2 client dependencies like this:

  container.RegisterType<IElasticClient, ElasticClient>(
        new InjectionConstructor(
            new ResolvedParameter<IConnectionSettingsValues>(),
            new OptionalParameter<IConnection>(),
            new OptionalParameter<IElasticsearchSerializer>(),
            new OptionalParameter<ITransport>()));

I was using NEST and ElasticSearch. Now I moved to NEST 2 and ElasticSearch 2 and I had to change INestSerializer into IElasticsearchSerializer

Unfortunately now I've got this error on ITransport

Using the generic type ITransport requires 1 type arguments

What should I pass to ITransport? I tried changing the line to:

 new OptionalParameter<ITransport<IConnectionConfigurationValues>>()));

but I get this exception at runtime:

The type Nest.ElasticClient does not have a constructor that takes the parameters (IConnectionSettingsValues, IConnection, IElasticsearchSerializer, ITransport`1)

What should I do now?

EDIT

The current constructors for the ElasticClient class are:

  • ()
  • (IConnectionSettingValues connSettings)
  • (ITransport<IConnectionSettingValues tran)
  • (Uri uri)

So basically I can pass nothing, a connection setting, a transport or the URL endpoint

My Elasticsearch 2 is using username and a password so I bet I should use either the second or the third constructor overload

来源:https://stackoverflow.com/questions/35695364/nest2-initialization-on-net-c-sharp-webapi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!