ElasticSearch ‐ 기본 검색 기능 및 작동 원리에 대한 이해 - dnwls16071/Backend_Study_TIL GitHub Wiki
- 역인덱스는 필드 값을 단어마다 쪼개서 찾기 쉽게 정리해놓은 목록이다.
$ POST /products/_doc
{
"name" : "Apple 2025 맥북 에어 13 M4 10코어"
}
❗각 단어별로 저장된 목록을 역인덱스라고 한다.
❗The index_options parameter controls what information is added to the inverted index for search and highlighting purposes. Only term-based field types like text and keyword support this configuration.
$ POST /products/_doc
{
"name" : "Apple 2025 맥북 에어 13 M4 10코어"
}
-
products
인덱스의name
필드값을 토큰으로 분리해 역인덱스로 저장하는 과정을 거친다. - 이 때, 문자열을 토큰으로 변환시켜주는 장치를 애널라이저(Analyzer)라고 한다.
- 캐릭터 필터 : 문자열을 토큰으로 자르기 전에 문자열을 다듬는 역할을 수행한다.
- 토크나이저 : 문자열을 토큰으로 자르는 역할을 수행한다.
- 토큰 필터 : 잘린 토큰을 최종적으로 다듬는 역할을 수행한다.
❗Only text fields support the analyzer mapping parameter.
❗The standard analyzer is the default analyzer which is used if none is specified. It provides grammar based tokenization (based on the Unicode Text Segmentation algorithm, as specified in Unicode Standard Annex #29) and works well for most languages.
- Tokenizer : Standard Tokenizer
- Token Filters Lower Case Token Filter
$ GET /_analyze
{
"text" : "Apple 2025 맥북 에어",
"analyzer" : "standard"
}
// Result
{
"tokens": [
{
"token": "apple",
"start_offset": 0,
"end_offset": 5,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "2025",
"start_offset": 6,
"end_offset": 10,
"type": "<NUM>",
"position": 1
},
{
"token": "맥북",
"start_offset": 11,
"end_offset": 13,
"type": "<HANGUL>",
"position": 2
},
{
"token": "에어",
"start_offset": 14,
"end_offset": 16,
"type": "<HANGUL>",
"position": 3
}
]
}
$ PUT /products
{
"settings": {
"analysis": {
"analyzer": {
"my_custom_analyzer": {
"type": "custom",
"tokenizer": "standard",
"char_filter": [
"html_strip"
],
"filter": [
"lowercase",
"asciifolding"
]
}
}
}
}
}
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "keyword",
"char_filter": [
"html_strip"
]
}
}
}
}
}
{
"settings": {
"analysis": {
"filter": {
"my_stop_filter": {
"type": "stop",
"stopwords": [
"in",
"the",
"days"
]
}
}
}
}
}
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "whitespace",
"filter": [ "stemmer" ]
}
}
}
}
}
"analyzer": {
"my_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["stemmer", "synonym"]
}
}##