DELETE korean_texts
PUT /korean_texts
{
"settings": {
"analysis": {
"tokenizer": {
"nori_user_dict": {
"type": "nori_tokenizer",
"decompound_mode": "none",
"user_dictionary": "user_dict.txt"
}
},
"filter": {
"nori_part_of_speech": {
"type": "nori_part_of_speech",
"stoptags": ["E", "IC", "J", "MAG", "MAJ", "MM", "NA", "NNB", "NNBC", "NP", "NR", "SC", "SE", "SF", "SH", "SL", "SN", "SP", "SSC", "SSO", "SY", "UNA", "VA", "VCN", "VCP", "VSV", "VV", "VX", "XPN", "XR", "XSA", "XSN", "XSV"]
},
"two_or_more_gram_filter": {
"type": "length",
"min": 2
}
},
"analyzer": {
"korean_noun_analyzer": {
"type": "custom",
"tokenizer": "nori_user_dict",
"filter": ["nori_part_of_speech", "two_or_more_gram_filter"]
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "korean_noun_analyzer",
"fielddata": true
}
}
}
}
POST /korean_texts/_doc/1
{
"content": "이것은 예시 문장입니다. 명사만 추출합니다."
}
POST /korean_texts/_doc/2
{
"content": "다른 예시 문장도 추가합니다. 명사 빈도수를 분석합니다."
}
POST /korean_texts/_search
{
"size": 0,
"aggs": {
"nouns": {
"terms": {
"field": "content",
"size": 10
}
}
}
}
POST /korean_texts/_close
POST /korean_texts/_open
POST /korean_texts/_analyze
{
"analyzer": "korean_noun_analyzer",
"text": "이것은 예시 문장입니다. 공항대교에서 유격슈를 만났다."
}
사용자 사전 관련 내용
- config 디렉토리내에 저장
- "단어,품사,가중치" 형식으로 저장 (ex. 바람,NNG,10)
- 품사의 목록 : https://lucene.apache.org/core/7_6_0/analyzers-nori/org/apache/lucene/analysis/ko/POS.Tag.html