I am using nest to implement elasticsearch in .net and am new to it. I am trying to map suggesters please help me with it. how to do that in c# using nest
curl -X PUT localhost:9200/songs/song/_mapping -d '{
"song" : {
"properties" : {
"name" : { "type" : "string" },
"suggest" : { "type" : "completion",
"index_analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true
}
}
}
}'
Find the complete code below. It creates a new ElasticClient
object and then adds the mapping song
to the index songs
. Make sure that index songs
already exists before you execute this code. You can also create the index songs
before creating the mapping through code anyways. I'll leave that upto you to figure out. Find an exhaustive example of how mappings can be created in Nest here .
var client = new ElasticClient(new ConnectionSettings(new Uri("http://localhost:9200")));
var response = client.Map<object>(d => d
.Index("songs")
.Type("song")
.Properties(props => props
.String(s => s
.Name("name"))
.Completion(c => c
.Name("suggest")
.IndexAnalyzer("simple")
.SearchAnalyzer("simple")
.Payloads())));
Debug.Assert(response.IsValid);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.