Upgrade from nest 0.11.0.0 to 5.5.0 Index and delete


#1

I'm very much a newbie, tasked with upgrading an older service
Given
private static ElasticClient ClientCreate(Uri uri)
{
var e = new Nest.ElasticClient(new ConnectionSettings(uri));
return e;
}

This is no longer valid syntax :
public void AlertSave(Alert alert)
{
var c = ClientCreate(_uri);
c.Index(alert,_indexName );
}
public void AlertDelete(Alert alert)
{
var c = ClientCreate(_uri);
c.Delete(alert,_indexName);
}

I got round it by creating the client with a default index - is this a sensible approach? is there a better one?
private static ElasticClient ClientCreate(Uri uri, string index)
{
var e = new Nest.ElasticClient(new ConnectionSettings(uri).DefaultIndex(index));
return e;
}
public void AlertSave(Alert alert)
{
var c = ClientCreate(_uri, _indexName);
c.Index(alert);
}
etc


(Russ Cam) #2

Please edit your question and format your code with </> button.

The default index is used if no index is specified on the request, and no index can be inferred for the type; check out the options for how an index name can be inferred. Usually, I tend to set up indices and type names to use for specific C# POCOs, using InferMappingFor<T>() on ConnectionSettings.

Also take a look at how an index name can be specified, using strings, C# types and infer methods.


(system) #3

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