How to get the equvalent of GET indexName using Nest .NET Library?


#1

When I run GET indexName against ES, i get a definition of the index. How does one do that with the Nest library?

I've tried client.GetIndex but that doesn't seem to do the trick. And I don't see any metadata specific methods.

An example would be great.


(Russ Cam) #2

Here are the index methods with NEST

var client = new ElasticClient();

// makes GET /<index> request
var getIndexResponse = client.GetIndex("<index>");

// makes GET /<index>/_settings request
var getIndexSettingsResponse = client.GetIndexSettings(i => i
    .Index("<index>")
);

// makes GET /<index>/_mapping request
var getMappingsResponse = client.GetMapping<object>(i => i
    .Index("<index>")
    .AllTypes()
);

#3

@forloop This works generally, but for some indexes the call fails. I am on version 1.7.6 so that might be the problem.

For instance, client.GetIndex(name); returns the following error:

Could not convert string to boolean: no. Path 'index', line 1, position 181.

Running GET /valuations_636727374057800495 yields the following, so something can't be parsed properly.

{
"valuations_636727374057800495": {
"aliases": {
"valuations": {}
},
"mappings": {
"propertyvaluation": {
"properties": {
"confidenceScore": {
"type": "integer",
"doc_values": true
},
"estimatedMax": {
"type": "integer",
"index": "no"
},
"estimatedMin": {
"type": "integer",
"index": "no"
},
"estimatedValue": {
"type": "integer",
"index": "no"
},
"estimationDate": {
"type": "date",
"doc_values": true,
"format": "dateOptionalTime"
},
"fipsMuniCode": {
"type": "short",
"doc_values": true
},
"fipsStateCode": {
"type": "byte",
"doc_values": true
},
"fsdScore": {
"type": "integer",
"index": "no"
},
"latitude": {
"type": "float",
"doc_values": true
},
"longitude": {
"type": "float",
"doc_values": true
},
"parcelNumber": {
"type": "string",
"index": "not_analyzed"
},
"pin": {
"type": "geo_point",
"fielddata": {
"loading": "eager"
},
"lat_lon": true
},
"propertyId": {
"type": "double",
"doc_values": true
},
"propertyValuationHistoryPoints": {
"properties": {
"date": {
"type": "date",
"index": "no",
"format": "dateOptionalTime"
},
"value": {
"type": "integer",
"index": "no"
}
}
},
"trustClass": {
"type": "string",
"index": "no"
}
}
}
},
"settings": {
"index": {
"creation_date": "1537158527410",
"number_of_shards": "6",
"number_of_replicas": "1",
"version": {
"created": "1070699"
},
"uuid": "T06-C4TZRPKmKdaGc91HOw"
}
},
"warmers": {}
}
}


(Russ Cam) #4

What version of the NEST client are you using? NEST 1.x should be used with 1.7.6


#5

I see. I'll just live with the errors since 1.x version is not code compatible with the latest NEST release.


(Russ Cam) #6

Elasticsearch 1.x is compatible with NEST 1.x, so you must use the latest NEST 1.x release, which is NEST 1.9.2. Note that Elasticsearch 1.7.6 and NEST 1.x are both end of life.

The equivalent methods in NEST 1.9.2 are

// makes GET /<index> request
var getIndexResponse = client.GetIndex(i => i.Index("<index>"));

// makes GET /<index>/_settings request
var getIndexSettingsResponse = client.GetIndexSettings(i => i
    .Index("<index>")
);

// makes GET /<index>/_mapping request
var getMappingsResponse = client.GetMapping<object>(i => i
    .Index("<index>")
    .Type("")
);


(system) #7

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