๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
1๏ธโƒฃ Web/๊ธฐํƒ€

[Web] ElasticSearch nori & Bulk API ํ™œ์šฉ

by seolhee2750 2023. 4. 2.

๐Ÿ“ ElasticSearch ๋ฐ nori ์„ค์น˜

์„ค์น˜๋Š” ์•„๋ž˜ ๋ธ”๋กœ๊ทธ๋ฅผ ์ฐธ๊ณ ํ–ˆ์Šต๋‹ˆ๋‹ค.

ElasticSearch ์„ค์น˜ํ•˜๊ธฐ (์œˆ๋„์šฐ 10) (tistory.com)

 

ElasticSearch ์„ค์น˜ํ•˜๊ธฐ (์œˆ๋„์šฐ 10)

1. ์—˜๋ผ์Šคํ‹ฑ ์„œ์น˜ ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€ ์ ‘์† www.elastic.co/kr/downloads/elasticsearch Download Elasticsearch Download Elasticsearch or the complete Elastic Stack (formerly ELK stack) for free and start searching and analyzing in minutes with Elastic.

team621.tistory.com

ElasticSearch ๋กœ์ปฌ ์„ค์น˜ํ•˜๊ธฐ — ์ฐฝ์Šˆ Area (tistory.com)

 

ElasticSearch ๋กœ์ปฌ ์„ค์น˜ํ•˜๊ธฐ

ElasticSearch๋Š” ์˜คํ”ˆ์†Œ์Šค ๊ฒ€์ƒ‰์—”์ง„์œผ๋กœ ์ด ๋ถ„์•ผ์— ๊ต‰์žฅํžˆ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŒ…์€ ์—˜๋ผ์Šคํ‹ฑ์„œ์น˜๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ ์œ„ํ•ด ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. + ์—˜๋ผ์Šคํ‹ฑ์„œ์น˜ ์ปค๋ฆฌ๋ฅผ ์‰ฝ๊ฒŒ ๋‚ ๋ฆฌ๊ธฐ์œ„ํ•ด ํ‚ค

lcs1245.tistory.com

์œˆ๋„์šฐ ์—˜๋ผ์Šคํ‹ฑ์„œ์น˜ + ๋…ธ๋ฆฌ์„ค์น˜(window elasticsearch nori) (tistory.com)

 

์œˆ๋„์šฐ ์—˜๋ผ์Šคํ‹ฑ์„œ์น˜ + ๋…ธ๋ฆฌ์„ค์น˜(window elasticsearch nori)

์œˆ๋„์šฐ ํ™˜๊ฒฝ์—์„œ ๋…ธ๋ฆฌ(nori) ๋ถ„์„๊ธฐ๋ฅผ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์€ ๋งค์šฐ ์‰ฝ์Šต๋‹ˆ๋‹ค. ์œˆ๋„์šฐ ๋ฒ„์ „์˜ ์—˜๋ผ์Šคํ‹ฑ ์„œ์น˜๋Š” zip ํ˜•ํƒœ๋กœ ๋˜์–ด ์žˆ์œผ๋ฉฐ ์••์ถ•์„ ํ‘ผ ๋‹ค์Œ์— ๋ฐฐ์น˜(bat)ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋Š” ํ˜•ํƒœ๋กœ ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.(202

lts0606.tistory.com

 

๐Ÿ’ก ํ…Œ์ŠคํŠธ

์„ฑ๊ณต์ ์œผ๋กœ ์„ค์น˜๋ฅผ ๋งˆ์ณค๋‹ค๋ฉด ๋จผ์ € ElasticSearch ๋ฐฐ์น˜ ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ ๋’ค,

์•„๋ž˜์™€ ๊ฐ™์€ ์š”์ฒญ์œผ๋กœ nori ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ๊นŒ์ง€ ํ…Œ์ŠคํŠธ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

๐Ÿ’ก nori๋ž€?

nori๋Š” ElasticSearch์—์„œ ์ œ๊ณตํ•˜๋Š” ํ•œ๊ธ€ ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ์ด๋‹ค.

 

์ด์ „์—๋Š” ElasticSearch๊ฐ€ ํ•œ๊ธ€ ํ˜•ํƒœ์†Œ ๋ถ„์„์„ ์ง€์›ํ•˜์ง€ ์•Š์•„์„œ

'์€์ „ํ•œ๋‹ข' ํ˜น์€ '์•„๋ฆฌ๋ž‘' ๋“ฑ์˜ ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ–ˆ์ง€๋งŒ,

ElasticSearch 6.4 ๋ฒ„์ „๋ถ€ํ„ฐ๋Š” ๊ธฐ๋ณธ์œผ๋กœ nori ํ•œ๊ธ€ ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ๋ฅผ ์ œ๊ณตํ•ด์ฃผ๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค.

(ํ˜•ํƒœ์†Œ ๋ถ„์„์ด๋ผ ํ•จ์€, ์˜์–ด๋กœ ๋ณด๋ฉด ed, s์™€ ๊ฐ™์ด ๋‹จ์–ด์— ๋ถ™์—ฌ ์“ธ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ž๋‚˜

์–ด๋ฏธ๋กœ ์“ฐ์ด๋Š” ๋‹จ์–ด ๋“ฑ์„ ๋ถ„์„ํ•˜์—ฌ ํ‚ค์›Œ๋“œ ๊ฒ€์ƒ‰์„ ๋•๋Š” ๊ฒƒ์ด๋‹ค.)

 

nori์˜ ๊ฒฝ์šฐ mecab-ko-dic ์‚ฌ์ „์„ ์ด์šฉํ•˜์ง€๋งŒ, ์‚ฌ์ „์„ ์••์ถ•ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ

๊ธฐ์กด ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ์™€ ๋น„๊ตํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ›จ์”ฌ ์ ๊ฒŒ ์“ฐ๊ณ  ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ๋ณด์ธ๋‹ค.

 


๐Ÿ“ Bulk API ํ™œ์šฉ

์ง„ํ–‰์ค‘์ธ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ์—ฌ๋Ÿฌ ์ด์œ ๋กœ ELK๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , Bulk API๋ฅผ ํ™œ์šฉํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๋‹ค. 

ElasticSearch ์ ์šฉ ๋ฐฉ์•ˆ ํƒ์ƒ‰ โ†—

 

์˜ค๋Š˜์€ ์šฐ๋ฆฌ ํ”„๋กœ์ ํŠธ์—์„œ Bulk API๋ฅผ ํ™œ์šฉํ•œ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณด๋ ค ํ•œ๋‹ค.

 

๐Ÿ’ก MySQL ๋ฐ์ดํ„ฐ ๋ณ€ํ™˜

๊ธฐ์กด์— ์‚ฌ์šฉํ•˜๋˜ MySQL์— ์ €์žฅ๋œ ๋ฐ์ดํ„ฐ๋ฅผ Bulk ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ

ElasticSearch์— ์ €์žฅํ•˜๋Š” ๊ณผ์ •์„ ์„œ์ˆ ํ•œ๋‹ค.

 

1๏ธโƒฃ SQL ์ฟผ๋ฆฌ ์ž‘์„ฑ

์•„๋ž˜์™€ ๊ฐ™์ด ์›ํ•˜๋Š” ํ…Œ์ด๋ธ”์—์„œ ์›ํ•˜๋Š” ์ปฌ๋Ÿผ๋งŒ ์„ ํƒํ•˜์—ฌ Bulk ํ˜•์‹ ๋ณ€ํ™˜์„ ์œ„ํ•œ ์ฟผ๋ฆฌ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์—ˆ๋‹ค.

select
	group_concat(concat("{'index':{'_id':", drink_id, "}}", '\n'),
	concat("{'drink_id':",drink_id,",'drink_name':'", drink_name,"','drink_image':'", drink_image,"'}") separator '\n')
as json from sulnaeeum.drink;

 

2๏ธโƒฃ group_concat ๊ธธ์ด ์ œํ•œ ๋ณ€๊ฒฝ

group_concat์˜ ๊ฒฝ์šฐ ๊ธฐ๋ณธ ๊ธธ์ด ์ œํ•œ์ด1024๋กœ ์„ค์ •๋˜์–ด์žˆ์œผ๋ฏ€๋กœ

์œ„ SQL ์ฟผ๋ฆฌ๋กœ ๋ฐ”๋กœ select ํ•  ์‹œ, 1024๊ฐœ ๋ฌธ์ž ์ด์ƒ์˜ ๊ฒฐ๊ณผ๋Š” ์ž˜๋ ค์„œ ์กฐํšŒ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

(Lost Connection ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€ ๋ฐœ์ƒ)

 

๋”ฐ๋ผ์„œ ์•„๋ž˜์™€ ๊ฐ™์ด group_concat์˜ ๊ธธ์ด ์ œํ•œ์„ ๋Š˜๋ ค์ค€ ๋’ค select๋ฅผ ์‹คํ–‰์‹œ์ผœ์•ผ ํ•œ๋‹ค.

# ํ˜„์žฌ group_concat์˜ ์ œํ•œ ๊ธธ์ด ํ™•์ธ
SHOW VARIABLES LIKE '%GROUP_CONCAT%';

# group_concat์˜ ๊ธธ์ด ์ œํ•œ ๋Š˜๋ ค์ฃผ๊ธฐ
SET SESSION group_concat_max_len = 150000000000;

 

3๏ธโƒฃ copy field

์ถœ๋ ฅ๋œ select ๊ฒฐ๊ณผ๋ฅผ ์šฐํด๋ฆญํ•˜์—ฌ Copy Field ์˜ต์…˜์„ ์„ ํƒํ•œ๋‹ค.

 

4๏ธโƒฃ Bulk ๋ฐ์ดํ„ฐ ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜

์œ„์˜ ๋ฐฉ์‹์œผ๋กœ ํ•„๋“œ๋ฅผ ๋ณต์‚ฌํ•ด์˜ค๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ๋ฐ˜ํ™˜๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

'{''index'':{''_index'':''1''}}
{''drink_id'':1,''drink_name'':''์• ํ”ผ์†Œ๋“œํ˜ธํ”„'',''drink_image'':''https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/1.jpg''}
{''index'':{''_index'':''2''}}
{''drink_id'':2,''drink_name'':''์• ํ”ผ์†Œ๋“œ ์ƒ๊ทธ๋ฆฌ์•„'',''drink_image'':''https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/2.jpg''}
{''index'':{''_index'':''3''}}
{''drink_id'':3,''drink_name'':''์• ํ”ผ์†Œ๋“œ ์• ํ”Œ'',''drink_image'':''https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/3.jpg''}
{''index'':{''_index'':''4''}}
{''drink_id'':4,''drink_name'':''์‹ฌ์ˆ  ์•Œ์“ฐ'',''drink_image'':''https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/4.jpg''}
{''index'':{''_index'':''5''}}
{''drink_id'':5,''drink_name'':''์•„์ด์‹ฑ ์ž๋ชฝ'',''drink_image'':''https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/5.jpg''}'

 

์—ฌ๊ธฐ์„œ ์ถ”๊ฐ€๋กœ ์•„๋ž˜ 3๊ฐ€์ง€ ์ž‘์—…์„ ํ•ด์ฃผ๋ฉด Bulk ๋ฐ์ดํ„ฐ ํ˜•์‹์œผ๋กœ ์™„๋ฒฝํžˆ ๋ณ€ํ™˜๋œ๋‹ค.

  1. ๋งจ ์ฒซ ๋ฒˆ์งธ์™€ ๋งˆ์ง€๋ง‰์— ์žˆ๋Š” ๋”ฐ์˜ดํ‘œ ํ•˜๋‚˜์”ฉ์„ ์‚ญ์ œ
  2. VisualStudio์—์„œ ๋”ฐ์˜ดํ‘œ ๋‘ ๊ฐœ๋ฅผ ๊ฒ€์ƒ‰ํ•œ ๋’ค ์Œ๋”ฐ์˜ดํ‘œ๋กœ replaceAll
  3. ๋งจ ๋งˆ์ง€๋ง‰ ํ–‰์— ์ค„ ๋ฐ”๊ฟˆ ํ•œ ๋ฒˆ ์ถ”๊ฐ€ํ•ด์ฃผ๊ธฐ

 

โœ” ์™„์„ฑ๋œ Bulk ๋ฐ์ดํ„ฐ ํ˜•์‹

{"index":{"_id":"1"}}
{"drink_id":1,"drink_name":"์• ํ”ผ์†Œ๋“œํ˜ธํ”„","drink_image":"https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/1.jpg"}
{"index":{"_id":"2"}}
{"drink_id":2,"drink_name":"์• ํ”ผ์†Œ๋“œ ์ƒ๊ทธ๋ฆฌ์•„","drink_image":"https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/2.jpg"}
{"index":{"_id":"3"}}
{"drink_id":3,"drink_name":"์• ํ”ผ์†Œ๋“œ ์• ํ”Œ","drink_image":"https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/3.jpg"}
{"index":{"_id":"4"}}
{"drink_id":4,"drink_name":"์‹ฌ์ˆ  ์•Œ์“ฐ","drink_image":"https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/4.jpg"}
{"index":{"_id":"5"}}
{"drink_id":5,"drink_name":"์•„์ด์‹ฑ ์ž๋ชฝ","drink_image":"https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/5.jpg"}

 

๐Ÿ’ฅ ์ฃผ์˜์‚ฌํ•ญ

์œ„์—์„œ ํ–ˆ๋˜ ๊ฒƒ์ฒ˜๋Ÿผ id ๊ฐ’์„ ์ง€์ •ํ•ด์ฃผ์ง€ ์•Š๊ณ ,

์œ„ ์ด๋ฏธ์ง€์ฒ˜๋Ÿผ "_index" : "drink" ์™€ ๊ฐ™์ด ํ•ด์ฃผ๋ฉด ์ž๋™์œผ๋กœ index๊ฐ€ ์ƒ์„ฑ๋˜์–ด ์ €์žฅ๋œ๋‹ค.

 

๋‚˜๋„ ์ฒ˜์Œ์—” ์ด์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ–ˆ๋Š”๋ฐ,

์ด๋ ‡๊ฒŒ ํ•  ๊ฒฝ์šฐ ์ถ”ํ›„ nori๋ฅผ ์ ์šฉ์ด ์ž˜ ์•ˆ๋˜๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

 

๋”ฐ๋ผ์„œ ๋ฏธ๋ฆฌ ์ธ๋ฑ์Šค๋ฅผ ๋งŒ๋“ค์–ด์ฃผ๋ฉด์„œ, nori๋ฅผ ์ ์šฉ์‹œ์ผœ์ค€ ๋’ค ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•ด์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค.

 

๐Ÿ’ก index ์ƒ์„ฑ

์•„๋ž˜์˜ PUT ์š”์ฒญ๊ณผ ํ•จ๊ป˜ Body์— ํ•ด๋‹น JSON ๋‚ด์šฉ์„ ๋„ฃ์–ด์ฃผ๋ฉด

nori tokenizer๋ฅผ ์ ์šฉํ•œ index ์ƒ์„ฑ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

http://localhost:9200/drink
{
  "settings": {
    "analysis": {
      "analyzer": {
        "nori": {
          "tokenizer": "nori_tokenizer"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "drink_name": {
        "type": "text",
        "fields": {
          "nori": {
            "type": "text",
            "analyzer": "nori"
          }
        }
      }
    }
  }
}

 

๐Ÿ’ก Bulk API๋ฅผ ์‚ฌ์šฉํ•œ ๋ฐ์ดํ„ฐ ์‚ฝ์ž…, ์‚ญ์ œ, ์กฐํšŒ, ๊ฒ€์ƒ‰

์ธ๋ฑ์Šค๋ฅผ ์ƒ์„ฑํ–ˆ์œผ๋‹ˆ ์ด์ œ ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ๊ณ  API๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋œ๋‹ค.

 

1๏ธโƒฃ ๋ฐ์ดํ„ฐ ์‚ฝ์ž…

์•„๋ž˜ ์š”์ฒญ์—, ์œ„์—์„œ ๋งŒ๋“  Bulk ๋ฐ์ดํ„ฐ๋ฅผ Binary๋กœ ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค.

curl -XPOST http://localhost:9200/drink/_bulk?pretty -H 'Content-Type: application/json' --data-binary @data.json

 

2๏ธโƒฃ ์กฐํšŒํ•˜์—ฌ ๋ฐ์ดํ„ฐ ํ™•์ธ

curl -XPOST 'localhost:9200/auto_complete/_search?pretty' -H 'Content-Type: application/json' -d'{
  "query": {
      "match_all": {}
  }
}'

 

3๏ธโƒฃ index ์‚ญ์ œ

curl -XDELETE http://localhost:9200/auto_complete?pretty -H 'Content-Type: application/json'

 

4๏ธโƒฃ nori tokenizer๋ฅผ ์ ์šฉํ•œ ํ‚ค์›Œ๋“œ ๊ฒ€์ƒ‰

์•„๋ž˜ GET ์š”์ฒญ๊ณผ ํ•จ๊ป˜ JSON์œผ๋กœ ๊ฒ€์ƒ‰ ๋‚ด์šฉ์„ ๋ณด๋‚ด์ฃผ๋ฉด ๋œ๋‹ค.

https://j8a707.p.ssafy.io/es/_search
{
  "query": {
      "match": {
          "drink_name.nori": "ํ˜ธ๋ž‘์ด๋ง‰๊ฑธ๋ฆฌ"
      }
  }
}

 

๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ

๋”๋ณด๊ธฐ

{ "took": 6, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 114, "relation": "eq" }, "max_score": 7.305012, "hits": [ { "_index": "drink", "_type": "_doc", "_id": "54", "_score": 7.305012, "_source": { "drink_id": 54, "drink_name": "ํ˜ธ๋ž‘์ด ์ƒ ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/54.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "139", "_score": 6.4983244, "_source": { "drink_id": 139, "drink_name": "๋งคํ™”๋งˆ๋ฆ„ ํ˜ธ๋ž‘์ด ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/139.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "126", "_score": 5.499996, "_source": { "drink_id": 126, "drink_name": "ํ˜ธ๋ž‘์ด๋ฐฐ๊ผฝ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/126.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "8", "_score": 2.0608451, "_source": { "drink_id": 8, "drink_name": "์ธ์ƒ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/8.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "39", "_score": 2.0608451, "_source": { "drink_id": 39, "drink_name": "์†ก๋ช…์„ญ ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/39.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "43", "_score": 2.0608451, "_source": { "drink_id": 43, "drink_name": "๊น€ํฌ ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/43.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "55", "_score": 2.0608451, "_source": { "drink_id": 55, "drink_name": "๋„๊ตฌ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/55.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "58", "_score": 2.0608451, "_source": { "drink_id": 58, "drink_name": "์˜ํƒ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/58.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "70", "_score": 2.0608451, "_source": { "drink_id": 70, "drink_name": "๋ฏธ์ƒ ๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/70.jpg" } }, { "_index": "drink", "_type": "_doc", "_id": "79", "_score": 2.0608451, "_source": { "drink_id": 79, "drink_name": "DOK๋ง‰๊ฑธ๋ฆฌ", "drink_image": "https://sulnaeeum.s3.ap-northeast-2.amazonaws.com/drink/79.jpg" } } ] } }

 

์ธ๋ฑ์Šค ์ƒ์„ฑ ์‹œ ์ž‘์„ฑํ–ˆ๋˜ Body ๋‚ด์šฉ์— ์˜ํ•ด

ํ•ด๋‹น ๋‹จ์–ด์— ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ฒฐ๊ณผ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

โž• ElasticSearch์—์„œ ๊ธฐ๋ณธ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” tokenizer๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒ€์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•

https://j8a707.p.ssafy.io/es/_search?q=drink_name:๋ง‰๊ฑธ๋ฆฌ

 


์˜ค๋Š˜์€ ๋กœ์ปฌ ํ™˜๊ฒฝ์—์„œ ElasticSearch์˜ nori์™€ Bulk API๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ •๋ฆฌํ–ˆ๋‹ค.

๋‹ค์Œ ๊ธ€์—์„œ๋Š” EC2 ํ™˜๊ฒฝ์—์„œ ElasticSearch๋ฅผ ์ ์šฉํ•˜๋Š” ๋ฐฉ์•ˆ์— ๋Œ€ํ•˜์—ฌ ์ •๋ฆฌํ•ด๋ณด๊ฒ ๋‹ค.

๋Œ“๊ธ€