我已尝试使用fluent API将tokenizer和分析器映射到我的索引,但它没有出现。字段映射有效。
var filters = new string[] { "standard",
"lowercase",
"stop",
"ngram" };
client.CreateIndex("defaultindexname", index => index
.Settings(f => f
.Analysis(analysis => analysis
.Tokenizers(tokenizers => tokenizers
.EdgeNGram("ngram", t => t
.MinGram(2)
.MaxGram(15)
)
)
.Analyzers(analyzers => analyzers
.Custom("auto-complete", a => a
.Filters("lowercase")
.CharFilters(filters)
.Tokenizer("standard")
)
)
)
)
.Mappings(m => m
.Map<Type>(l => l
.Dynamic(DynamicMapping.Ignore)
.Properties(p => p
.String(s => s
.Name(n => n.Name)
.Boost(5)
)
.String(s => s
.Name(n => n.Address)
)
.Number(s => s
.Name(n => n.Id)
)
.Completion(c => c
.Name(n => n.Suggest)
.Payloads()
)
.Nested<NestedType>(o => o
.Dynamic(DynamicMapping.Ignore)
.Name(n => n.Branches)
.Properties(ilfbp => ilfbp
.Number(s => s
.Name(n => n.Id)
)
.String(s => s
.Name(n => n.Name)
)
.String(s => s
.Name(n => n.Address)
)
)
)
)
)
));
我已经成功地在Sense中使用JSON创建了tokenizer和分析器。
PUT /defaultindexname/_settings
{
"settings": {
"analysis": {
"filter": {
"ngram": {
"type": "ngram",
"min_gram": 2,
"max_gram": 10
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"ngram"
]
}
}
}
}
}
如何使用流畅的api添加标记器和分析器?