I am using following code for searching the articleid and control fields. it will hold the 2 fields values. But I can't access these two fields values. HERE search<> is dynamic.
var searchrange = _client.Search<dynamic>(s => s
.Indices("kb_v2").Types("kb")
.From(0).Size(10)
.Fields("articleid","control")
.Query(q => q
.Range(r =>r
.OnField("articleid")
.Greater("2")
.Lower("5"))));
can you explain How to get the this two fields values..
The search response (
ISearchResponse
type) has a FieldSelections property which holds the results and details. With the older version of Nest, one had to loop over the Hits property to find the value of each field.More on how to use the FieldSelections in ElastichSearch.net client is mentioned in this Unit test here
Since Elasticsearch 1.0 fields are always returned as a
Dictionary<string, object[]>
on hits to access these in NEST you can use:See this PR for more details on the syntax.