Proper way to do multi field with NEST
elasticsearch, nest
Solution
Checkout this answer.
Basically, you could do something like this:
client.CreatIndex("tweets", c => c
.AddMapping<Tweet>(m => m
.MapFromAttributes()
.Properties(props => props
.MultiField(mf => mf
.Name(t => t.Message)
.Fields(fs => fs
.String(s => s.Name(t => t.Message).Analyzer("standard"))
.String(s => s.Name(t => t.Message.Suffix("raw")).Index(FieldIndexOption.not_analyzed)))))));
Problem
I want to implement full text search and tokenized search with NEST, so I want to get multifield like that : ``` "tweet": { "properties": { "message": { "type": "string", "store": true, "fields": { "raw": { "type": "string", "index": "not_analyzed" } } } } } ``` Currently, my mapping with NEST is ``` [ElasticType(Name = "tweet")] internal class Tweet { [ElasticProperty(Name = "message")] public string Message { get; set; } } ``` I searched in the documentation on NEST and ElasticSearch.net but nothing came by. Is there any option to get a raw field inside a field automatically or should I define a nested class and specify myself the raw field (I would prefer a cleaner way) ?