νμ¬ μλΌμ€ν±μμΉλ₯Ό μ΄μ©ν΄ μμ§ν λ°μ΄ν°(MBTI νμ λ³ ν μ€νΈ λ°μ΄ν°)λ₯Ό μ‘°ννλ νλ‘μ νΈλ₯Ό μ§ννκ³ μμ΅λλ€. μ¬κΈ°μ MBTI νμ κ³Ό μ€λ§νΈν°(μμ΄ν° λλ κ°€λμ)μ μκ΄μ±μ λΆμνκΈ° μν΄ ESμ 쿼리λ₯Ό νλνκ³ μμ΅λλ€.
μΈλ±μ€ ꡬμ±
μ½ν μΈ λ΄λΆμμ λͺ μ¬λ§ μΆμΆνμ¬ λΆμνκΈ° μν΄ nori_nounμ΄λΌλ λΆμκΈ°λ₯Ό λ³λλ‘ μμ±νμ¬ νλλ‘ μ€μ νμ΅λλ€.
{
"mbti" : {
"aliases" : { },
"mappings" : {
"properties" : {
"comment_cnt" : {
"type" : "integer"
},
"contents" : {
"type" : "text",
"fields" : {
"full" : {
"type" : "keyword"
},
"nori_mixed" : {
"type" : "text",
"analyzer" : "nori_mixed",
"search_analyzer" : "standard"
},
"nori_noun" : {
"type" : "text",
"analyzer" : "nori_pos_noun",
"search_analyzer" : "standard"
}
}
},
"doc_url" : {
"type" : "text"
},
"keyword" : {
"type" : "keyword"
},
"like_cnt" : {
"type" : "integer"
},
"platform" : {
"type" : "keyword"
},
"published_at" : {
"type" : "date"
},
"title" : {
"type" : "text"
},
"writer" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "1",
"provided_name" : "mbti",
"creation_date" : "1649761141991",
"analysis" : {
"filter" : {
"pos_filter" : {
"type" : "nori_part_of_speech",
"stoptags" : [
"VV",
"VA",
"VX",
"VCP",
"VCN",
"MM",
"MAG",
"MAJ",
"IC",
"J",
"E",
"XPN",
"XSA",
"XSN",
"XSV",
"SP",
"SSC",
"SSO",
"SC",
"SE",
"UNA"
]
}
},
"analyzer" : {
"nori_mixed" : {
"filter" : "shingle",
"tokenizer" : "nori_t_mixed"
},
"nori_pos_noun" : {
"filter" : "pos_filter",
"type" : "custom",
"tokenizer" : "nori_t_mixed"
}
},
"tokenizer" : {
"nori_t_mixed" : {
"type" : "nori_tokenizer",
"decompound_mode" : "mixed"
}
}
},
"number_of_replicas" : "1",
"uuid" : "e8w9oHlLSyqF5oDzviz0KA",
"version" : {
"created" : "7170299"
}
}
}
}
}
κ° MBTI νμ λ³ μ€λ§νΈν° μ νΈλ
GET mbti/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"contents.nori_noun": {
"query": "ENFP"
}
}
},
{
"match_phrase": {
"contents": {
"query": "μμ΄ν°",
"boost": 2
}
}
}
]
}
}
}
Match 쿼리μ μ½ν μΈ λ΄λΆμ MBTI νμ μ΄ μλμ§μ λν΄ μ°μ μ‘°ννλ€. κ·Έλ¦¬κ³ match_phraseλ‘ μμ΄ν°μ boostλ₯Ό νμ¬ μμ΄ν°μ΄ ν¬ν¨λ μλ¬Έμ΄ μμ κ²μλλλ‘ μΏΌλ¦¬λ₯Ό λ§λ€μμ΅λλ€.
μ¬μ€ match_phrase λ ꡬ문, μ¦ “μμ΄ν° κΏν”μ²λΌ ꡬ문μ λ§€μΉ μ λλ₯Ό boost ν΄μ£ΌκΈ° λλ¬Έμ μ μ¬λ‘μμλ μ μ ν μ¬μ© μ¬λ‘λ μλλλ€. μλλ “ENFP μμ΄ν°”μΌλ‘ κ²μνμ¬ κ° λ¨μ΄ κ°μ Distanceλ₯Ό κ²μ Score μκ³ λ¦¬μ¦μΌλ‘ μ¬μ©νλ €κ³ νμ§λ§ μ€ν¨νμ¬ μ°μ match_phraseλ₯Ό μ¬μ©νμμ΅λλ€.
ν΄κ²°λ°©λ²μ? (μλλΆν°λ μ½μ§μ μμ¬μ λλ€...)
#1 Should λ₯Ό μ¬μ©ν μ‘°ν
Shouldμ κ²½μ° νν λ§νλ or 쑰건μΌλ‘ 쑰건μ ν¬ν¨λ λ¨μ΄κ° μμλ‘ μ¬λΌμ€λλ‘(μ¦ score μ μκ° λ λμμ§ μ μλλ‘) 쿼리 λ³κ²½
GET mbti/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"contents.nori_noun": {
"query": "ENFP"
}
}
}
],
"should": [
{
"match": {
"contents": {
"query": "μμ΄ν°",
"boost": 2
}
}
},
{
"match": {
"contents": {
"query": "ENFP",
"boost": 1
}
}
}
]
}
}
}