본문 바로가기

IT/Elasticsearch

[Elasticsearch] Elasticsearch In Action - 5

5.3 분석 API로 텍스트 분석하기 #settings #analyzer #tokenizer #mapping


curl -XPOST 'localhost:9200/myindex?pretty' -d '{

"settings" : {

"number_of_shards" : 2,

"number_of_replicas" : 1,

"index" : {

"analysis" : {

"analyzer" : {

"myCustomAnalyzer" : {

"type" : "custom",

"tokenizer" : "myCustomTokenizer",

"filter" : ["myCustomFilter1", "myCustomFilter2"],

"char_filter" : ["myCustomCharFilter"]

}

},

"tokenizer" : {

"myCustomTokenizer" : {

"type" : "letter"

}

},

"filter" : {

"myCustomFilter1" : {

"type" : "lowercase"

},

"myCustomFilter2" : {

"type" : "kstem"

}

},

"char_filter" : {

"myCustomCharFilter" : {

"type" : "mapping",

"mappings" : ["ph=>f", "u=>you"]

}

}

}

}

},

"mappings" : {

"document" : {

"properties" : {

"description" : {

"type" : "string",

"analyzer" : "myCustomAnalyzer"

}

}

}

}

}'


curl -XPOST 'localhost:9200/_analyze?analyzer=standard&pretty' -d 'share your experience with NoSql & big data technologies'

curl -XPOST 'localhost:9200/myindex/_analyze?analyzer=myCustomAnalyzer&pretty' -d 'share your experience with NoSql & big data technologies'


5.3.4 텀 백터 API를 사용하여 색인된 텀에 관해 배워보기 #termvector


#텀이 어떻게 구성되었는지 알 수 있다. ("1"은 id이다.)

curl 'localhost:9200/get-together/group/1/_termvector?pretty'


#필드를 지정하고 전체 문서에서의 텀 비중까지 알 수 있다.

curl 'localhost:9200/get-together/group/1/_termvector?pretty' -d '{

"fields" : ["title", "desc"],

"term_statistics" : true

}'



5.4 분석기, 토크나이저, 토큰 필터


5.4.1 내장 분석기


표준 분석기 - standard

단순 분석기 - simple

화이트스페이스 - whitespace

불용어 - stop

키워드 - keyword

패턴 - pattern

언어 및 다국어

스노우볼 - snowball


5.4.2 토큰화


표준 토크나이저 - standard

키워드 - keyword

문자 - letter

소문자화 - lowercase

화이트스페이스 - whitespace

패턴 - pattern


5.4.3 토큰 필터


표준 - standard

소문자화 - lowercase

길이 - length : 토큰의 길이가 min보다 작거나 max보다 길면 제거한다.

...

"analysis" : {

"filter" : {

"my-length-filter" : {

"type" : "length",

"max" : 8,

"min" : 2

}

}

}

... #한글의 경우도 길이를 정확하게 체크해주는가..?


불용어 - stop

#불용어 사전을 정의 할 수도 있다던데, 한글도 가능한지..?

truncate

trim

limit token count

반전 - reverse

유일성 - unique

#오직 유일한 토큰만 유지한다. --> 원래 안해주나...?

asciifolding

동의어 - synonym


이후 5장 마무리까지 나오는 내용들은... 한글 데이터에는 어울리지 않는다고 판단. 여기에 기록하지 않겠음... (~p238)



'IT > Elasticsearch' 카테고리의 다른 글

[Elasticsearch] download url  (0) 2016.12.01
[Elasticsearch] Monitoring Rest Api  (0) 2016.12.01
[Elasticsearch] Elasticsearch In Action - 3,4  (0) 2016.11.20
[config 설정]  (0) 2016.09.18
[ElasticSearch-1 start stop]  (0) 2016.09.12