์ฉ์ด ์ฟผ๋ฆฌ
์ฉ์ด ์ฟผ๋ฆฌ๋ ์๋ฒฝํ๊ฒ ๋งค์นญ๋๋ ๋จ์ด ํน์ ๋ฌธ๊ตฌ๋ฅผ ๊ฐ์ ธ์จ๋ค. match ์ฟผ๋ฆฌ์๋ ๋ค๋ฅด๊ฒ ๋ฌธ์ฅ์ ๋ํ full-text-match ๊ฒ์์ด๊ธฐ ๋๋ฌธ์ ๋ฌธ์ฅ ์ ์ฒด๋ฅผ ์๊ณ ์์ด์ผ ํ๋ค.
๊ธฐ์กด review ์ธ๋ฑ์ค์์ review ๋ฐ์ดํฐ๊ฐ text ํ์ ์ผ๋ก ๋์ด ์์ด term ์ฟผ๋ฆฌ๊ฐ ์๋ํ์ง ์๋ ๋ฌธ์ ๊ฐ ์์๋ค. ๊ทธ๋์ ์๋กญ๊ฒ ์ธ๋ฑ์ค๋ฅผ ๊ตฌ์ฑํ์๋ค.
"mappings": {
"properties": {
"prd_id": {
"type": "text"
},
"review_id": {
"type": "text"
},
"review": {
"type": "text",
"fields": {
"full": {
"type": "keyword"
},
// nori ํํฐ๋ฅผ ์๋ํ์ง๋ง ์คํจํ์๋ค.. ๋ค์์ ๋ค์!
"nori_mixed": {
"type": "text",
"analyzer": "nori_analyzer",
"search_analyzer": "standard"
}
}
},
"genders": {
"type": "rank_features"
}
}
}
์ด๋ฒ ์ธ๋ฑ์ค์์๋ review ํ์์ fields ๋ฅผ ์์ฑํ์๋ค. ๊ทธ๋ฆฌ๊ณ keyword ํ์ ์ผ๋ก ํ๋ ์์ธ ๋ด์ฉ์ ์ ์ํ์๋ค.
Elastic search ๊ณต์ ๋ฌธ์ - https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html
Term ์ฟผ๋ฆฌ ์์
GET review_nlp/_search
{
"query":{
"term": {
"review.keyword": {
"value": "๋งจํฌ๋งจ ๋ญ์ด์ง ๊ณ ๋ฏผํ์ ๋ค๋ฉด ์ด ๋งจํฌ๋งจ ์ถ์ฒ๋๋ ค์"
}
}
}
}
์ฌ๋ฌ ํ๋์ ์ฟผ๋ฆฌ ์์ฒญํ๊ธฐ
๊ฒ์ํ๊ณ ์ ํ๋ ์ฉ์ด๋ ๊ตฌ์ ์ด ์ ํํ ์ด๋ค ํ๋์ ์๋์ง ๋ชจ๋ฅด๋ ๊ฒฝ์ฐ๊ฐ ์์ ๋ ์ฌ์ฉํ๋ค.
์ธ๋ฑ์ค ๊ตฌ์ฑ
"properties": {
"prd_id": {
"type": "text"
},
"title": {
"type": "text"
},
"url": {
"type": "text"
},
"brand": {
"type": "text"
},
"hashtag": {
"type": "text"
},
"category1": {
"type": "text"
},
"category2": {
"type": "text"
}
}
์ฟผ๋ฆฌ ๊ฒ์
GET product/_search
{
"query": {
"multi_match": {
"query": "๋งจํฌ๋งจ",
"fields": [
"title",
"hashtag"
]
}
}
}
์ ๋ชฉ ๋ฐ ํด์ํ๊ทธ ํ๋์ ๊ด๋ จ ํค์๋๋ฅผ ๊ฒ์ํ๋ค.
์๋ฆฌ๋ โ๋งจํฌ๋งจโ์ด๋ผ๋ ์ฉ์ด๋ฅผ ๋งค์น ์ฟผ๋ฆฌ๋ก ๊ฒ์ํ์ฌ ๊ฐ ํ๋๋ณ ์ค์ฝ์ด๋ฅผ ๊ตฌํ๊ณ ๊ทธ์ค ๊ฐ์ฅ ํฐ ๊ฐ์ ๋ํ ์ค์ฝ์ด๋ก ๊ณ์ฐํ๋ค.
๋ํ ์์ผ๋์นด๋๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ํ๋์ ๋ํ ๊ฒ์์ด ๊ฐ๋ฅํ๋ค.
// category1, category2์ ๋ํด ๊ฒ์
GET product/_search
{
"query": {
"multi_match": {
"query": "๋งจํฌ๋งจ",
"fields": [
"category*"
]
}
}
}
'Elastic Search' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Elastic Search] MBTI ๊ฒ์ ํ๋ก์ ํธ - 1. ๊ฒ์ Score ํ๋ (0) | 2022.04.12 |
---|---|
[Elastic Search] ๊ฒ์ ๊ตฌํํ๊ธฐ(with Fast API) (0) | 2022.02.15 |
[Elastic Search] Nori Tokenizer & Filter ์ ์ฉ๊ธฐ (0) | 2022.02.09 |
[Elastic Search] Query ์คํฐ๋-3ํธ ํ๋ ๊ฐ์ค์น, ๋ ผ๋ฆฌ ์ฟผ๋ฆฌ, ํจํด ๊ฒ์ (2) | 2022.02.03 |
[Elastic Search] Query ์คํฐ๋-1ํธ Match, Match Phrase (0) | 2022.01.27 |