elastic_tutorial/The Elasticsearch Documentation/8_analyzer/2_analyzer.es
2025-04-09 09:37:23 +03:30

120 lines
4.5 KiB
Erlang
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
PUT /firstindex
{
"settings": {
"index": {
"analysis": {
"index": {
"analysis": {
"analyzer": {
"My-analyzer-Name": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [],
"filter": [
"My-Normalizer-Name"
]
}
}
}
},
"filter": {
"My-Normalizer-Name": {
"type": "synonym",
"lenient": true,
"_comment": "نعيم, حميد => نعيم",
"synonyms": [
"آب زي, آبزي => آب زي",
"آرامش بخش, آرامش‌بخش => آرامش بخش",
"شوقي, شوق => شوق",
"مقصودشان, مقصود => مقصود",
"عفاهما, عفا => عفا",
"عفاتك, عفا => عفا",
"عقالاته, عقال => عقال"
]
}
}
}
}
}
}
// آنالایزر های خود را در analyzer تعریف کنید.
// "type": "custom" --> نوع آناایزر
// "tokenizer": "standard" --> هنگام تبدیل کلمات به کلمات دیگر، باید کلمات را بر یک اساسی جدا کرد، برای این کار از tokenizer استفاده میکنیم
// بعضی زبان ها یک سری کارکتر برای جدا کردن کلمات دارند و از standard tokenizer استفاده نمیکند
// char_filter --> اسم نرمالایزر های شما برای کاراکتر ها
// filter --> اسم نرمالایزر های فیلتری شما
PUT /firstindex
{
"settings": {
"properties": {
"mintro": {
"type": "text",
"fields": {
"fa": {
"type": "text",
"analyzer": "normal_analyzer_persian",
"search_analyzer": "normal_analyzer_persian",
"search_quote_analyzer": "phrase_analyzer_persian"
}
}
}
}
},
"index": {
"analysis": {
"index": {
"analysis": {
"analyzer": {
"My-analyzer-Name": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [],
"filter": [
"My-Normalizer-Name"
]
}
}
}
},
"filter": {
"My-Normalizer-Name": {
"type": "synonym",
"lenient": true,
"_comment": "نعيم, حميد => نعيم",
"synonyms": [
"آب زي, آبزي => آب زي",
"آرامش بخش, آرامش‌بخش => آرامش بخش",
"شوقي, شوق => شوق",
"مقصودشان, مقصود => مقصود",
"عفاهما, عفا => عفا",
"عفاتك, عفا => عفا",
"عقالاته, عقال => عقال"
]
}
}
}
}
}
// "mintro": {
// "type": "text",
// "fields": {
// "fa": {
// "type": "text",
// "analyzer": "normal_analyzer_persian",
// "search_analyzer": "normal_analyzer_persian",
// "search_quote_analyzer": "phrase_analyzer_persian"
// }
// }
// }
// mintro --> نام فیلد
// fields > fa --> فیلد های داخلی، مثلا برای جستجو فارسی
// analyzer --> آنالایزر روی داده هایی که به این فیلد ارسال میشوند
// search_analyzer --> آنالایز بر متنی که با آن روی این فیلد سرچ میشود
// search_quote_analyzer --> آنالایزر بر متنی که هنگام سرچ درون کوتیشن قرار دارد