Persian analyzer
출처: 문서
본문
페르시아어 애널라이저
내장된 persian 애널라이저는 다음 명령어를 사용해 text 필드에 적용할 수 있어요.
PUT /persian-index
{
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "persian"
}
}
}
}
{% include copy-curl.html %}
어간 제외(stem exclusion)
다음 명령어를 사용하면 이 언어 애널라이저에 stem_exclusion을 사용할 수 있어요.
PUT index_with_stem_exclusion_persian_analyzer
{
"settings": {
"analysis": {
"analyzer": {
"stem_exclusion_persian_analyzer": {
"type": "persian",
"stem_exclusion": ["حکومت", "تأیید"]
}
}
}
}
}
{% include copy-curl.html %}
페르시아어 애널라이저 내부 구조
persian 애널라이저는 다음 구성 요소로 이루어져 있어요.
-
토크나이저:
standard -
char 필터:
mapping -
토큰 필터:
- lowercase
- decimal_digit
- normalization (아랍어)
- normalization (페르시아어)
- stop (페르시아어)
- keyword
커스텀 페르시아어 애널라이저
다음 명령어를 사용해 커스텀 페르시아어 애널라이저를 만들 수 있어요.
PUT /persian-index
{
"settings": {
"analysis": {
"filter": {
"persian_stop": {
"type": "stop",
"stopwords": "_persian_"
},
"persian_keywords": {
"type": "keyword_marker",
"keywords": []
}
},
"char_filter": {
"null_width_replace_with_space": {
"type": "mapping",
"mappings": [ "\\u200C=>\\u0020"]
}
},
"analyzer": {
"persian_analyzer": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [ "null_width_replace_with_space" ],
"filter": [
"lowercase",
"decimal_digit",
"arabic_normalization",
"persian_normalization",
"persian_stop",
"persian_keywords"
]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "persian_analyzer"
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
애널라이저를 사용해 생성된 토큰을 살펴보려면 다음 요청을 사용하세요.
POST /persian-index/_analyze
{
"field": "content",
"text": "دانشجویان در دانشگاههای ایرانی تحصیل میکنند. شمارههای آنها ۱۲۳۴۵۶ است."
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{"token": "دانشجويان","start_offset": 0,"end_offset": 9,"type": "<ALPHANUM>","position": 0},
{"token": "دانشگاه","start_offset": 13,"end_offset": 20,"type": "<ALPHANUM>","position": 2},
{"token": "ايراني","start_offset": 25,"end_offset": 31,"type": "<ALPHANUM>","position": 4},
{"token": "تحصيل","start_offset": 32,"end_offset": 37,"type": "<ALPHANUM>","position": 5},
{"token": "شماره","start_offset": 47,"end_offset": 52,"type": "<ALPHANUM>","position": 8},
{"token": "123456","start_offset": 63,"end_offset": 69,"type": "<NUM>","position": 12}
]
}