Nest using system indices


(Marc Antoine Jutras) #1

Hi all,

I'm trying to get my cluster stats out of the .monitoring-* index with NEST and I can't get a result out so I was wondering if it does not allow querying system indices?

TermQuery termQuery = new TermQuery
{
     Field = "type",
     Value = "cluster_stats"
};  
response = await _client.SearchAsync<ElasticClusterStat>(s => s
                                              .From(0)
                                              .Size(1)
                                              .Index(".monitoring-*")
                                               .Query(q => q
                                                     .Term(tq => termQuery)
                                               )

);

I set my connection to provide details (from OnRequestCompleted) and I can see the request (JSON) passed and there no hits in the result. When I copy paste my request in my kibana console, I get thousands of hits...

Thanks,


(Russ Cam) #2

I suspect you also need to set .Type(...) with the document type in the .monitoring indices


(Marc Antoine Jutras) #3

It did actually work! Why is that? The .Type(...) is always required? Isn't it going to be deprecated in 7.0.0 of elasticsearch?

Thanks @forloop

I was using the guide here: https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/writing-queries.html and it did not specify that the document type had to be specified for a query.


(Russ Cam) #4

Type is being deprecated, but it's still needed for 6.x.

In the absence of an explicit .Type() method call or any conventions set up on ConnectionSettings with

  • .DefaultTypeName()
  • ..DefaultTypeNameInferrer()
  • use of DataContractAttribute or ElasticsearchTypeAttribute on the POCO type

NEST infers the type name by lowercasing the POCO type name. Check out type inference for more details