Reputation: 33
I am using ElasticProperty attributes to define my index type mapping. This works:
[ElasticProperty(Boost = 2)]
public string Title { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)]
public string ActivityType { get; set; }
I create my index and everything looks good (I'm just copying the affected props):
"properties": {
"activityType": {
"type": "string",
"index": "not_analyzed"
},
"title": {
"type": "string",
"boost": 2
}
}
BUT, when I drop the mapping, change the Analyzer and reindex watch what happens:
[ElasticProperty(Boost = 2, Analyzer = "keyword")]
public string Title { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)]
public string ActivityType { get; set; }
Result:
"properties": {
"activityType": {
"type": "string"
},
"title": {
"type": "string"
}
}
Can someone explain what's happening here? It seems that adding the Analyzer parameter forces the mapping to be generated dynamically. Why?
Upvotes: 0
Views: 1338
Reputation: 12429
Make sure that on your application startup you're calling the following:
private readonly IElasticClient _client;
//initialize _client
_client.Map<YourTypeHere>(m => m.MapFromAttributes());
That code will apply any new mapping that you have.
Upvotes: 1