The documentation seems to indicate that I can return a subset of the fields instead of the entire document. here is my code:
var result = client.Search<MyObject>(s => s .Fields(f => f.Title) .Query(q => q .QueryString(qs => qs .OnField("title") .Query("the"))));
I am looking for the word "the" in the "title" field and I just want to return "title". my result.Documents object contains 10 objects, each of which has a null value.
I see the values โโI want, but it is deep in the answer to the search: result.Hits [0] .Fields.FieldValues โโ[0] ...
is there a better way to get a list of returned 'title' fields?
my mapping for data (truncated) is ...
{ "myidex": { "mappings": { "myobject": { "properties": { "title": { "type": "string" }, "artists": { "properties": { "id": { "type": "string", "index": "not_analyzed", "analyzer": "fullTerm" }, "name": { "type": "string", "index": "not_analyzed", "analyzer": "fullTerm" } } } } } } } }
and my class objects are like this:
[Table("MyTable")] [Serializable] [ElasticType(Name="myobject")] public class MyObject { [ElasticProperty] public string Title { get; set; } [JsonIgnore] public string Artistslist { get; set; } [ElasticProperty(Analyzer = "caseInsensitive")] public List<Person> Artists { get; set; } } [Serializable] public class Person { [ElasticProperty(Analyzer = "fullTerm", Index = FieldIndexOption.not_analyzed)] public string Name { get; set; } [ElasticProperty(Analyzer = "fullTerm", Index = FieldIndexOption.not_analyzed)] public string Id { get; set; } }
The artist list comes from my data source (sql), then I parse it into a new List object before indexing the data.
elasticsearch nest
bigerock
source share