英文:
use python library for custom filter analyzer in elasticsearch
问题
我想为波斯语文本创建一个“index”,并为其创建词干处理器。以下是如何将“PersianStemmer” Python库实现到Elasticsearch的“analyzer”中的示例:
PUT my_index
{
"settings": {
"analysis": {
"filter": {
"persian_stemmer": {
"type": "stemmer",
"name": "persian"
}
},
"analyzer": {
"persian_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase", "persian_stemmer"]
}
}
}
},
"mappings": {
"properties": {
"description": {
"type": "text",
"analyzer": "persian_analyzer"
}
}
}
}
此示例将创建一个名为“persian_analyzer”的自定义分析器,该分析器使用标准分词器,然后应用小写转换和波斯文词干处理器。描述字段使用此分析器进行分析。请确保您已经安装了“PersianStemmer” Python库,并且已将其集成到您的Elasticsearch环境中。
英文:
I want to create an index
for persian-language
text and I want to create stemmer for that, this is english-stemming
for description
field
PUT my_index
{
"mappings": {
"properties": {
"description": {
"type": "text",
"analyzer": "english"
}
}
},
"settings": {
"analysis":{
"filter": {
"english_stemmer": {
"type": "stemmer",
"language": "english"
}
}
}
}
}
Now I want to know how can implement the PersianStemmer
python library to elasticsearch analyzer
?
答案1
得分: 1
你需要为此创建自定义分析器:
PUT my_index
{
"settings": {
"analysis": {
"filter": {
"persian_stemmer": {
"type": "stemmer",
"language": "persian"
}
},
"analyzer": {
"persian_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"persian_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"description": {
"type": "text",
"analyzer": "persian_analyzer"
}
}
}
}
英文:
You need to create custom analyzer for that:
PUT my_index
{
"settings": {
"analysis": {
"filter": {
"persian_stemmer": {
"type": "stemmer",
"language": "persian"
}
},
"analyzer": {
"persian_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"persian_stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"description": {
"type": "text",
"analyzer": "persian_analyzer"
}
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论