Reputation: 1848
I am trying to map multiple analyzers to a field in my elastic type. If I use an ElasticAttribute to map an analyzer:
[ElasticProperty(Analyzer = "fulltext")]
public string LongDescription { get; set; }
and I look at the request created I get:
"name": {
"type": "string",
"analyzer": "fulltext"
},
In order to map multiple analyzers to the same field, I use Fluent mapping and add a multifield:
.Properties(prop => prop
.MultiField(mf => mf
.Name(p => p.Name)
.Fields(f => f
.String(
s =>
s.Name(n => n.Name)
.IndexAnalyzer("autocomplete_analyzer")
.IncludeInAll(false)
.Index(FieldIndexOption.not_analyzed))
.String(
s =>
s.Name(n => n.Name)
.IndexAnalyzer("fulltext")
.IncludeInAll(false)
.Index(FieldIndexOption.not_analyzed))
)
)
)
The request generated looks like this:
"name": {
"type": "multi_field",
"fields": {
"name": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "autocomplete_analyzer",
"include_in_all": false
},
"name": {
"type": "string",
"index": "not_analyzed",
"index_analyzer": "fulltext",
"include_in_all": false
}
}
},
I am specifically interested in the "analyzer"/"index_analyzer" properties. With fluent mapping, I can only set IndexAnalyzer or SearchAnalyzer. I understand the difference between IndexAnalyzer and SearchAnalyzer, but what is the "analyzer" property when I use an ElasticAttribute? Does that just mean the Index and Search are set the same?
Upvotes: 1
Views: 4923
Reputation: 13536
Just specifying analyzer
is indeed setting index_analyzer
and search_analyzer
at the same time. analyzer
is an elasticsearch property and not some magic behavior from NEST.
The fluent mapping is missing the .Analyzer()
method, this is now added in 1.0!
Upvotes: 3