Elasticsearch NEST API 7.8 西班牙语分析器
Elasticsearch NEST API 7.8 Spanish Analyzer
有人可以告诉我们如何使用 NEST 语法为以下内容定义分析器:
西班牙语需要带有西班牙语停用词和西班牙语词干分析器的标准分析器。
文档都看了,除了英文分析器,其他都看不懂。
非常感谢。
默认Spanish analyzer is already configured in the way you described. Remaining thing is to tell elasticsearch to use it. Fortunately NEST folks prepared a very detailed and comprehensive doc about index mapping configuration. You can found it here.
例如,您可以像下面那样使用 fluent mappping 来使用西班牙语分析器配置您的字段
await client.Indices.CreateAsync("my_index", i => i
.Map<Document>(m => m
.Properties(p => p
.Text(t => t.Name(n => n.Title).Analyzer("spanish")))));
public class Document
{
public int Id { get; set; }
public string Title { get; set; }
}
以上,将创建具有以下映射的索引
{
"my_index":{
"mappings":{
"properties":{
"title":{
"type":"text",
"analyzer":"spanish"
}
}
}
}
}
希望对您有所帮助。
有人可以告诉我们如何使用 NEST 语法为以下内容定义分析器: 西班牙语需要带有西班牙语停用词和西班牙语词干分析器的标准分析器。
文档都看了,除了英文分析器,其他都看不懂。 非常感谢。
默认Spanish analyzer is already configured in the way you described. Remaining thing is to tell elasticsearch to use it. Fortunately NEST folks prepared a very detailed and comprehensive doc about index mapping configuration. You can found it here.
例如,您可以像下面那样使用 fluent mappping 来使用西班牙语分析器配置您的字段
await client.Indices.CreateAsync("my_index", i => i
.Map<Document>(m => m
.Properties(p => p
.Text(t => t.Name(n => n.Title).Analyzer("spanish")))));
public class Document
{
public int Id { get; set; }
public string Title { get; set; }
}
以上,将创建具有以下映射的索引
{
"my_index":{
"mappings":{
"properties":{
"title":{
"type":"text",
"analyzer":"spanish"
}
}
}
}
}
希望对您有所帮助。