Meilisearch 설치 · 17 min read · Oct 26, 2025
Debian 12에서 Meilisearch 설치 및 구성 방법

Meilisearch는 Rust 언어로 작성된 오픈 소스 검색 엔진입니다. Rust로 작성되었기 때문에 실행하는 데 필요한 리소스가 적고 단일 명령줄 바이너리를 사용하여 실행할 수 있습니다. 설치 과정은 다른 검색 엔진보다 간단하며 단계가 적습니다. 기능으로는 퍼지 매칭과 스키마 없는 인덱싱이 포함됩니다. 데모 목적으로 웹 프론트엔드가 제공됩니다. JavaScript, Python, PHP, Ruby 등 여러 언어로 제공되는 다양한 라이브러리를 통해 다양한 웹 애플리케이션에 통합할 수 있습니다.
이 튜토리얼에서는 Debian 12 서버에 Meilisearch를 프로덕션 환경에서 설치하고 여러 간단한 검색을 수행하는 방법을 배웁니다.
전제 조건
최소 2GB의 RAM을 갖춘 Debian 12를 실행하는 서버.
sudo 권한이 있는 비루트 사용자.
간단한 방화벽(UFW)이 활성화되어 실행 중입니다.
서버를 가리키는
meilisearch.example.com과 같은 완전한 도메인 이름(FQDN). 이는 프록시 서버를 사용하여 SSL을 통해 Meilisearch를 제공하려는 경우 유용합니다.모든 것이 업데이트되었습니다.
$ sudo apt update && sudo apt upgrade튜토리얼에 필요한 몇 가지 필수 패키지가 필요합니다. 이 중 일부는 이미 서버에 설치되어 있을 수 있습니다.
$ sudo apt install curl wget nano software-properties-common dirmngr apt-transport-https ca-certificates lsb-release debian-archive-keyring gnupg2 ufw unzip -y
1단계 - 방화벽 구성
패키지를 설치하기 전에 첫 번째 단계는 방화벽을 구성하여 HTTP 및 HTTPS 연결을 허용하는 것입니다.
방화벽 상태를 확인합니다.
$ sudo ufw status다음과 유사한 내용을 볼 수 있어야 합니다.
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)HTTP 및 HTTPS 포트를 허용합니다.
$ sudo ufw allow http
$ sudo ufw allow https확인을 위해 상태를 다시 확인합니다.
$ sudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80/tcp ALLOW Anywhere
443/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
443/tcp (v6) ALLOW Anywhere (v6)2단계 - Meilisearch 설치
Meilisearch를 설치하는 방법에는 여러 가지가 있습니다. 우리는 바이너리 파일을 서버에 복사하는 가장 간단한 방법을 사용할 것입니다.
Meilisearch를 설치합니다.
$ curl -L https://install.meilisearch.com | sh바이너리를 실행 가능하게 만듭니다.
$ chmod +x meilisearch현재 바이너리는 다운로드한 디렉토리에서만 사용할 수 있습니다. 어디서나 사용할 수 있도록 바이너리 파일을 /usr/local/bin 디렉토리로 이동합니다.
$ sudo mv ./meilisearch /usr/local/bin/Meilisearch가 제대로 설치되고 실행되고 있는지 확인합니다.
$ meilisearch --version
meilisearch 1.7.63단계 - Meilisearch용 시스템 사용자 생성
루트로 Meilisearch를 실행하면 보안 문제가 발생할 수 있습니다. 이를 피하기 위해 Meilisearch를 실행할 시스템 사용자를 생성합니다.
$ sudo useradd -d /var/lib/meilisearch -b /bin/false -m -r meilisearch4단계 - Meilisearch 구성
앞으로 나아가기 전에 Meilisearch가 인증 프로세스에 사용하는 마스터 키를 생성해야 합니다. OpenSSL 명령줄 유틸리티를 사용하여 생성할 수 있습니다. 다음 명령을 실행하여 30자 길이의 마스터 키를 생성합니다. 마스터 키의 길이는 아무거나 선택할 수 있습니다. 길수록 좋습니다.
$ openssl rand -hex 3030자 길이의 키와 유사한 출력을 받아야 합니다. 이 값을 복사해야 하며, 이후 단계에서 필요합니다.
65ed5fc15848f7ceb8e646d4928fcf79f494cec239a2874cacd118e42611Meilisearch GitHub 리포지토리에서 최신 구성 파일을 가져와 /etc 디렉토리에 복사합니다.
$ sudo sh -c 'curl https://raw.githubusercontent.com/meilisearch/meilisearch/latest/config.toml > /etc/meilisearch.toml'편집을 위해 엽니다.
$ sudo nano /etc/meilisearch.toml데이터베이스 경로, 덤프 경로, 스냅샷 디렉토리 및 작업 환경을 구성하고 인증을 위해 이전에 생성한 마스터 키를 추가하기 위해 파일의 다음 줄을 업데이트합니다.
구성 파일의 업데이트된 값은 다음과 같아야 합니다.
env = "production"
master_key = "173e95f077590ed33dad89247247be8d8ce8b6722ccc87829aaefe3207be"
db_path = "/var/lib/meilisearch/data"
dump_dir = "/var/lib/meilisearch/dumps"
snapshot_dir = "/var/lib/meilisearch/snapshots"Meilisearch는 정기적으로 데이터를 익명으로 수집합니다. 다음 옵션을 사용하여 이를 비활성화해야 합니다. Meilisearch의 텔레메트리를 비활성화하려면 주석을 제거합니다.
no_analytics = true기본적으로 Meilisearch는 시스템에서 사용 가능한 RAM의 3분의 2를 초과하지 않습니다. 다음 변수를 주석 해제하고 설정하여 이를 제어할 수 있습니다. 정확하고 정확하게 값을 지정할 수 있습니다.
max_indexing_memory = "1 GiB"Meilisearch는 사용 가능한 CPU 코어의 절반 이상을 사용하지 않습니다. 그러나 다음 변수를 주석 해제하고 설정하여 이 값을 제어할 수 있습니다.
max_indexing_threads = 1이 값을 머신의 CPU 코어 수보다 더 크게 설정하면 Meilisearch에 사용 가능한 최대 코어 수를 사용하도록 지시합니다.
알아야 할 또 다른 설정은 Meilisearch가 수용할 수 있는 최대 페이로드의 양입니다. 기본값은 100MB로 설정되어 있습니다. 다음 변수를 구성하여 변경할 수 있습니다.
http_payload_size_limit = "100 MB"작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 프롬프트가 표시되면 Y를 입력합니다.
5단계 - 디렉토리 생성 및 권한 부여
Meilisearch가 데이터베이스, 데이터베이스 덤프 및 스냅샷을 저장할 디렉토리를 생성합니다.
$ sudo mkdir /var/lib/meilisearch/dumps -p
$ sudo mkdir /var/lib/meilisearch/snapshots이 디렉토리의 소유자 및 그룹을 Meilisearch용으로 생성한 시스템 사용자로 설정합니다.
$ sudo chown -R meilisearch:meilisearch /var/lib/meilisearchMeilisearch 바이너리 파일의 소유자 및 그룹을 설정합니다.
$ sudo chown meilisearch:meilisearch /usr/local/bin/meilisearch디렉토리에 적절한 권한을 설정합니다.
$ sudo chmod 750 /var/lib/meilisearch6단계 - Meilisearch를 서비스로 실행
Meilisearch를 검색 요청에 항상 사용할 수 있도록 하려면 시스템 서비스로 실행하는 것이 좋습니다. 이를 위해 서비스 파일을 생성해야 합니다.
/etc/systemd/system/meilisearch.service를 생성하고 편집을 위해 엽니다.
$ sudo nano /etc/systemd/system/meilisearch.service다음 코드를 붙여넣습니다.
[Unit]
Description=Meilisearch
After=systemd-user-sessions.service
[Service]
Type=simple
WorkingDirectory=/var/lib/meilisearch
ExecStart=/usr/local/bin/meilisearch --config-file-path /etc/meilisearch.toml
User=meilisearch
Group=meilisearch
[Install]
WantedBy=multi-user.targetCtrl + X를 눌러 파일을 저장하고 프롬프트가 표시되면 Y를 입력합니다.
서비스를 활성화합니다.
$ sudo systemctl enable meilisearchMeilisearch 서비스를 시작합니다.
$ sudo systemctl start meilisearch 서비스 상태를 확인합니다.
$ sudo systemctl status meilisearch다음과 유사한 출력을 받아야 합니다.
? meilisearch.service - Meilisearch
Loaded: loaded (/etc/systemd/system/meilisearch.service; enabled; preset: enabled)
Active: active (running) since Fri 2024-05-03 03:02:53 UTC; 5s ago
Main PID: 1008 (meilisearch)
Tasks: 6 (limit: 2251)
Memory: 23.0M
CPU: 10ms
CGroup: /system.slice/meilisearch.service
??1008 /usr/local/bin/meilisearch --config-file-path /etc/meilisearch.toml
May 03 03:02:53 meilisearch meilisearch[1008]: Commit date: "unknown"
May 03 03:02:53 meilisearch meilisearch[1008]: Package version: "1.7.6"
May 03 03:02:53 meilisearch meilisearch[1008]: Anonymous telemetry: "Disabled"
May 03 03:02:53 meilisearch meilisearch[1008]: A master key has been set. Requests to Meilisearch won't be authorized unless you provide an authentication key.
May 03 03:02:53 meilisearch meilisearch[1008]: Check out Meilisearch Cloud! https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=engine&utm_medium=cli
May 03 03:02:53 meilisearch meilisearch[1008]: Documentation: https://www.meilisearch.com/docs
May 03 03:02:53 meilisearch meilisearch[1008]: Source code: https://github.com/meilisearch/meilisearch
May 03 03:02:53 meilisearch meilisearch[1008]: Discord: https://discord.meilisearch.com
May 03 03:02:53 meilisearch meilisearch[1008]: 2024-05-03T03:02:53.891366Z INFO actix_server::builder: starting 2 workers
May 03 03:02:53 meilisearch meilisearch[1008]: 2024-05-03T03:02:53.891396Z INFO actix_server::server: Actix runtime found; starting in Actix runtimeMeilisearch가 설치되고 실행되고 있습니다. 이제 Nginx 서버를 사용하여 서비스를 외부에 노출하고 Let’s Encrypt를 사용하여 SSL을 통해 제공하겠습니다.
7단계 - Nginx 설치
Debian 12는 이전 버전의 Nginx를 제공합니다. 최신 버전을 설치하려면 공식 Nginx 리포지토리를 다운로드해야 합니다.
Nginx의 서명 키를 가져옵니다.
$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/nullNginx의 메인라인 버전 리포지토리를 추가합니다.
$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list시스템 리포지토리를 업데이트합니다.
$ sudo apt updateNginx를 설치합니다.
$ sudo apt install nginx설치를 확인합니다. Debian 시스템에서는 다음 명령이 sudo와 함께만 작동합니다.
$ sudo nginx -v
nginx version: nginx/1.25.5Nginx 서버를 시작합니다.
$ sudo systemctl start nginx서비스 상태를 확인합니다.
$ sudo systemctl status nginx
? nginx.service - nginx - 고성능 웹 서버
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: active (running) since Fri 2024-05-03 03:04:02 UTC; 5s ago
Docs: https://nginx.org/en/docs/
Process: 1699 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 1700 (nginx)
Tasks: 3 (limit: 2251)
Memory: 2.9M
CPU: 7ms
CGroup: /system.slice/nginx.service
??1700 "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf"
??1701 "nginx: worker process"
??1702 "nginx: worker process"
May 03 03:04:02 meilisearch systemd[1]: Starting nginx.service - nginx - 고성능 웹 서버...
May 03 03:04:02 meilisearch systemd[1]: Started nginx.service - nginx - 고성능 웹 서버.8단계 - SSL 설치
SSL 인증서를 생성하기 위해 Certbot을 설치해야 합니다. Certbot을 Debian의 리포지토리를 사용하여 설치하거나 Snapd 도구를 사용하여 최신 버전을 가져올 수 있습니다. 우리는 Snapd 버전을 사용할 것입니다.
Debian 12는 Snapd가 설치되어 있지 않습니다. Snapd 패키지를 설치합니다.
$ sudo apt install -y snapd다음 명령을 실행하여 Snapd 버전이 최신인지 확인합니다.
$ sudo snap install core && sudo snap refresh coreCertbot을 설치합니다.
$ sudo snap install --classic certbot다음 명령을 사용하여 Certbot 명령이 /usr/bin 디렉토리에서 실행될 수 있도록 심볼릭 링크를 생성합니다.
$ sudo ln -s /snap/bin/certbot /usr/bin/certbotCertbot이 제대로 작동하는지 확인합니다.
$ certbot --version
certbot 2.10.0다음 명령을 실행하여 SSL 인증서를 생성합니다.
$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d meilisearch.example.com위 명령은 서버의 /etc/letsencrypt/live/meilisearch.example.com 디렉토리에 인증서를 다운로드합니다.
Diffie-Hellman 그룹 인증서를 생성합니다.
$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096시스템d 타이머 목록을 확인합니다. Certbot은 자동으로 갱신을 위해 타이머를 설치하고 시작합니다.
$ sudo systemctl list-timers스케줄된 서비스 중 하나로 snap.certbot.renew.service를 찾을 수 있습니다.
NEXT LEFT LAST PASSED UNIT ACTIVATES ---------------------------------------------------------------------------------------------------------------------------------------
Fri 2024-05-03 17:17:15 UTC 14h left Fri 2024-05-03 02:54:42 UTC 11min ago apt-daily.timer apt-daily.service
Fri 2024-05-03 06:42:20 UTC 3h 36min left Fri 2024-05-03 02:54:42 UTC 11min ago apt-daily-upgrade.timer apt-daily-upgrade.service
Fri 2024-05-03 10:39:00 UTC 7h left - - snap.certbot.renew.timer snap.certbot.renew.serviceSSL 갱신이 제대로 작동하는지 확인하기 위해 프로세스를 드라이 런합니다.
$ sudo certbot renew --dry-run오류가 없으면 모든 설정이 완료된 것입니다. 인증서는 자동으로 갱신됩니다.
9단계 - Nginx 구성
편집을 위해 /etc/nginx/nginx.conf 파일을 엽니다.
$ sudo nano /etc/nginx/nginx.confinclude /etc/nginx/conf.d/*.conf; 줄 앞에 다음 줄을 추가합니다.
server_names_hash_bucket_size 64;Ctrl + X를 눌러 파일을 저장하고 프롬프트가 표시되면 Y를 입력합니다.
편집을 위해 /etc/nginx/conf.d/meilisearch.conf 파일을 생성하고 엽니다.
$ sudo nano /etc/nginx/conf.d/meilisearch.conf다음 코드를 붙여넣습니다. meilisearch.example.com을 도메인 이름으로 바꿉니다.
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
http3 on;
quic_retry on;
server_name meilisearch.example.com;
access_log /var/log/nginx/meilisearch.access.log;
error_log /var/log/nginx/meilisearch.error.log;
ssl_certificate /etc/letsencrypt/live/meilisearch.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/meilisearch.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/meilisearch.example.com/chain.pem;
ssl_session_timeout 5m;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_early_data on;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
location / {
proxy_pass http://localhost:7700;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# enforce HTTPS
server {
listen 80;
listen [::]:80;
server_name meilisearch.example.com;
return 301 https://$host$request_uri;
}Ctrl + X를 눌러 파일을 저장하고 프롬프트가 표시되면 Y를 입력합니다.
Nginx 구성을 확인합니다.
$ sudo nginx -tNginx 서버를 재시작합니다.
$ sudo systemctl restart nginxMeilisearch가 이제 실행 중이며 https://meilisearch.example.com URL을 통해 사용할 수 있습니다. URL을 열면 다음 텍스트가 표시됩니다.
{"status":"Meilisearch is running"}이 URL은 명령줄을 통해 검색하는 데만 사용할 수 있습니다. 프론트엔드를 통해 Meilisearch에 액세스하려면 다른 CMS 또는 소프트웨어와 통합해야 하며, 이는 이 튜토리얼의 범위를 벗어납니다. Meilisearch는 내장된 프론트엔드 인터페이스를 제공하지만, 이는 개발 목적으로 사용할 때만 작동합니다. 구성 파일에서 인스턴스의 환경을 development로 변경하고 Meilisearch를 재시작하여 인터페이스를 활성화할 수 있습니다. 다음과 비슷하게 보일 것입니다.

프로덕션 환경에서는 Meilisearch를 다른 CMS와 통합해야 합니다.
이제 문서를 인덱싱하고 검색에 사용할 수 있도록 시작합시다.
10단계 - Meilisearch에 샘플 데이터 로드
Meilisearch 프로젝트는 The Movie Database (TMDB)에서 스크랩한 데이터로 구성된 샘플 JSON 형식의 영화 파일을 제공합니다. 파일을 다운로드합니다.
$ wget https://www.meilisearch.com/movies.jsontail 명령을 실행하여 데이터의 일부를 확인할 수 있습니다. 다음과 비슷하게 보일 것입니다.
$ tail -n 3 movies.json
{"id":460070,"title":"J.T. LeRoy","overview":"A young woman named Savannah Knoop spends six years pretending to be a transgender writer named JT Leroy, the made-up literary persona of her sister-in-law.","genres":["Drama"],"poster":"https://image.tmdb.org/t/p/w500/43ffZhMCWQhzMneGP4kDWoPV48X.jpg","release_date":1556236800},
{"id":460071,"title":"Lizzie","overview":"Massachusetts, 1892. An unmarried woman of 32 and a social outcast, Lizzie lives a claustrophobic life under her father's cold and domineering control. When Bridget Sullivan, a young maid, comes to work for the family, Lizzie finds a sympathetic, kindred spirit, and a secret intimacy soon blossoms into a wicked plan.","genres":["Crime","Drama","Thriller"],"poster":"https://image.tmdb.org/t/p/w500/z2iuBcwznen3kC9z4LeOzBSz1BB.jpg","release_date":1536883200}
]각 개별 항목에는 id, 제목, 포스터 이미지 링크, 영화 개요, 출시 날짜 및 장르 목록이 포함되어 있습니다. 출시 날짜는 EPOCH 형식입니다.
curl을 사용하여 HTTP POST 요청을 통해 Meilisearch에 데이터를 로드합니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/documents' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 65ed5fc15848f7ceb8e646d4928fcf79f494cec239a2874cacd118e42611' \
--data-binary @movies.json명령 인수를 살펴보겠습니다:
- -X POST - HTTP POST 요청을 수행하고 데이터를 전송함을 지정합니다.
- -H Content-Type - 파일 콘텐츠 유형을 지정합니다.
- -H Authorization: Bearer - 요청과 함께 마스터 키를 전달합니다.
- –data-binary - 포함할 파일을 지정합니다.
여기서는 /indexes/movies/documents 위치에 새로운 Meilisearch 인덱스를 생성하고 있습니다. 요청이 대기열에 추가되었다는 유사한 출력을 받아야 합니다. Meilisearch는 모든 요청을 비동기적으로 처리합니다.
{"taskUid":0,"indexUid":"movies","status":"enqueued","type":"documentAdditionOrUpdate","enqueuedAt":"2024-05-03T03:12:55.599798591Z"}위 명령을 http://localhost:7700 대신 https://meilisearch.example.com으로 바꾸어 실행할 수도 있으며, 동일하게 작동합니다. 이 튜토리얼의 모든 명령에 대해 그렇게 할 수 있지만, 단순성을 위해 http://localhost:7700 URL을 고수하겠습니다.
요청 상태를 확인하는 다음 명령을 실행합니다.
$ curl -X GET 'http://localhost:7700/indexes/movies/tasks/0'유사한 출력을 받아야 합니다.
{"uid":0,"indexUid":"movies","status":"succeeded","type":"documentAddition","details":{"receivedDocuments":19547,"indexedDocuments":19546},"duration":"PT29.866920116S","enqueuedAt":"2024-05-03T03:13:18.233702815Z","startedAt":"2024-05-03T03:19:45.370142371Z","finishedAt":"2024-05-03T03:20:05.108395540Z"}이것은 작업이 완료되었으며 영화 데이터베이스가 이제 완전히 인덱싱되어 사용 준비가 되었음을 알려줍니다.
11단계 - 검색을 위한 제한된 키 사용
읽기 가능한 명령줄 JSON 형식을 돕는 도구가 필요합니다. 이를 jq라고 합니다. 다음 명령을 실행하여 설치합니다.
$ sudo apt install -y jq구성 파일에 마스터 키를 추가했지만, 각 요청과 함께 다시 전달해야 합니다. 진행하기 전에 읽기 전용 모드를 활성화할 수 있는 더 제한된 키가 필요합니다. Meilisearch는 기본적으로 읽기 전용 키를 생성합니다. 이를 가져옵니다.
$ curl -X GET 'http://localhost:7700/keys' -H 'Authorization: Bearer 65ed5fc15848f7ceb8e646d4928fcf79f494cec239a2874cacd118e42611' | jq유사한 출력을 받아야 합니다.
{
"results": [
{
"name": "Default Search API Key",
"description": "Use it to search from the frontend",
"key": "591e51d2f6700ead7ba134a7aed0966d72e2022e43847caf48df3e4800c9279a",
"uid": "d004073b-b813-4016-82cb-7995df5149f6",
"actions": [
"search"
],
"indexes": [
"*"
],
"expiresAt": null,
"createdAt": "2024-05-03T03:02:53.887256411Z",
"updatedAt": "2024-05-03T03:02:53.887256411Z"
},
{
"name": "Default Admin API Key",
"description": "Use it for anything that is not a search operation. Caution! Do not expose it on a public frontend",
"key": "0f3cdcfe5d9a56273d6c708f068a82382a97b629b70f4962f969687b5e327196",
"uid": "b4fc2f96-4347-4750-9ba6-2da73c26e2bd",
"actions": [
"*"
],
"indexes": [
"*"
],
"expiresAt": null,
"createdAt": "2024-05-03T03:02:53.886580786Z",
"updatedAt": "2024-05-03T03:02:53.886580786Z"
}
],
"offset": 0,
"limit": 20,
"total": 2
}이제부터는 Default Search API key를 사용하여 검색을 수행합니다.
12단계 - 샘플 데이터 검색
Meilisearch를 사용하여 검색하는 방법에는 두 가지가 있습니다. API를 통해 명령줄을 사용하거나 웹 인터페이스를 사용할 수 있습니다. 웹 인터페이스는 상당히 제한적이며 개발 환경에서만 작동하고, API는 Meilisearch를 사용하는 권장 방법입니다. 검색을 프로덕션용으로 구성했으므로 명령줄 방법만 사용합니다.
API를 통해 검색하는 것은 HTTP POST 요청을 통해 데이터를 업로드하는 것과 같습니다. API의 /search 엔드포인트에 요청을 합니다. 예를 들어, 제목에 saint라는 단어가 포함된 영화를 검색해 보겠습니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 591e51d2f6700ead7ba134a7aed0966d72e2022e43847caf48df3e4800c9279a' \
--data-binary '{ "q": "saint" }' | jqJSON 형식으로 다음과 같은 출력을 받아야 합니다.
{
"hits": [
{
"id": 25248,
"title": "Saint Ralph",
"overview": "This Canadian made comedy/drama, set in Hamilton, Ontario in 1954, is a sweet and - at times - goofy story that becomes increasingly poignant as the minutes tick by. It's the fictional tale of a wayward 9th grader, Ralph (Adam Butcher), who is secretly living on his own while his widowed, hospitalized mother remains immersed in a coma. Frequently in trouble with Father Fitzpatrick (Gordon Pinsent), the principal of his all-boys, Catholic school, Ralph is considered something of a joke among peers until he decides to pull off a miracle that could save his mother, i.e., winning the Boston Marathon. Coached by a younger priest and former runner, Father Hibbert (Campbell Scott), whose cynicism has been lifted by the boy's pure hope, Ralph applies himself to his unlikely mission, fending off naysayers and getting help along a very challenging path from sundry allies and friends.",
"genres": [
"Comedy",
"Drama"
],
"poster": "https://image.tmdb.org/t/p/w500/3MdWgqUunIBWnc7mYi2dtZrD54Y.jpg",
"release_date": 1123200000
},
{
"id": 26894,
"title": "Saint Sinner",
"overview": "In 1815 a monk, Tomas Alcala, unwittingly unleashes two female succubi, Munkar and Nakir, upon an unsuspecting 21st century. He is chosen by God to travel through the centuries and stop the demons' rampage.",
"genres": [
"Fantasy",
"Horror",
"Science Fiction",
"TV Movie"
],
"poster": "https://image.tmdb.org/t/p/w500/cxljKsfUI6PVFPIgPvsesUWHai4.jpg",
"release_date": 1035590400
},
{
"id": 27023,
"title": "Saint John of Las Vegas",
"overview": "An ex-gambler is lured back into the game by a veteran insurance-fraud investigator.",
"genres": [
"Comedy"
],
"poster": "https://image.tmdb.org/t/p/w500/kN4Vur1SccouDR0k3tmJXJHdrXw.jpg",
"release_date": 1264723200
},
...Meilisearch의 퍼지 매칭 기능을 테스트하여 비슷한 발음의 단어를 사용하여 정확한 검색을 수행할 수 있습니다. 이는 오타를 내더라도 올바른 결과를 기대할 수 있습니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 591e51d2f6700ead7ba134a7aed0966d72e2022e43847caf48df3e4800c9279a' \
--data-binary '{ "q": "seint" }' | jq여기서는 saint를 seint로 잘못 입력했지만 Meilisearch는 여전히 saint라는 단어가 포함된 항목을 반환합니다.
{
"hits": [
{
"id": 10105,
"title": "Saints and Soldiers",
"overview": "Five American soldiers fighting in Europe during World War II struggle to return to Allied territory after being separated from U.S. forces during the historic Malmedy Massacre.",
"genres": [
"War",
"Drama",
"Action",
"Adventure",
"History"
],
"poster": "https://image.tmdb.org/t/p/w500/efhqxap8fLi4v1GEXVvakey0z3S.jpg",
"release_date": 1063238400
},
{
"id": 25248,
"title": "Saint Ralph",
"overview": "This Canadian made comedy/drama, set in Hamilton, Ontario in 1954, is a sweet and - at times - goofy story that becomes increasingly poignant as the minutes tick by. It's the fictional tale of a wayward 9th grader, Ralph (Adam Butcher), who is secretly living on his own while his widowed, hospitalized mother remains immersed in a coma. Frequently in trouble with Father Fitzpatrick (Gordon Pinsent), the principal of his all-boys, Catholic school, Ralph is considered something of a joke among peers until he decides to pull off a miracle that could save his mother, i.e., winning the Boston Marathon. Coached by a younger priest and former runner, Father Hibbert (Campbell Scott), whose cynicism has been lifted by the boy's pure hope, Ralph applies himself to his unlikely mission, fending off naysayers and getting help along a very challenging path from sundry allies and friends.",
"genres": [
"Comedy",
"Drama"
],
"poster": "https://image.tmdb.org/t/p/w500/3MdWgqUunIBWnc7mYi2dtZrD54Y.jpg",
"release_date": 1123200000
},
{
"id": 26894,
"title": "Saint Sinner",
"overview": "In 1815 a monk, Tomas Alcala, unwittingly unleashes two female succubi, Munkar and Nakir, upon an unsuspecting 21st century. He is chosen by God to travel through the centuries and stop the demons' rampage.",
"genres": [
"Fantasy",
"Horror",
"Science Fiction",
"TV Movie"
],
"poster": "https://image.tmdb.org/t/p/w500/cxljKsfUI6PVFPIgPvsesUWHai4.jpg",
"release_date": 1035590400
},
…13단계 - 검색 순위 조정 및 데이터 필터링
검색 엔진은 특정 필드의 중요성에 따라 특정 결과에 우선 순위를 부여하는 방법을 알면 더 나은 결과를 반환할 수 있습니다. Meilisearch에는 검색 결과를 개선하기 위해 구성할 수 있는 기본 편향 규칙 세트가 있습니다.
하지만 먼저 Meilisearch에서 설정한 순위 규칙을 확인해야 합니다.
$ curl -X GET 'http://localhost:7700/indexes/movies/settings/ranking-rules' -H 'Authorization: Bearer 0f3cdcfe5d9a56273d6c708f068a82382a97b629b70f4962f969687b5e327196'다음과 같은 출력을 받게 됩니다.
["words","typo","proximity","attribute","sort","exactness"]- words - 결과는 일치하는 용어의 수에 따라 내림차순으로 정렬됩니다.
- typo - 결과는 오타 수에 따라 오름차순으로 정렬됩니다. 오타가 적은 쿼리가 상단에 반환됩니다.
- proximity - 결과는 일치하는 용어 간의 거리가 증가함에 따라 정렬됩니다.
- attribute - 결과는 속성 순위 순서에 따라 정렬됩니다.
- sort - 결과는 쿼리 시 결정된 매개변수에 따라 정렬됩니다.
- exactness - 결과는 쿼리 단어와 일치하는 단어의 유사성에 따라 정렬됩니다.
Meilisearch 공식 문서에서 관련성에 대해 더 읽을 수 있습니다.
편향 규칙 순서를 변경하려면 다음 명령을 실행합니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/settings/ranking-rules' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 0f3cdcfe5d9a56273d6c708f068a82382a97b629b70f4962f969687b5e327196' \
--data-binary '[
"words",
"typo",
"proximity",
"release_date:asc",
"attribute",
"sort",
"exactness",
"rank:desc"
]'이제 검색 결과를 필터링할 수 있습니다. 먼저 Meilisearch에 특정 속성만 사용하여 검색하도록 요청하고 의미 없는 속성인 id는 제외합니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/settings' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 0f3cdcfe5d9a56273d6c708f068a82382a97b629b70f4962f969687b5e327196' \
--data-binary '{
"searchableAttributes": [
"title",
"overview",
"genres"
]
}'여기서는 title, overview, genres 속성만 사용하여 검색을 수행하여 더 나은 결과를 제공합니다.
다음으로, 검색 결과를 표시할 특정 속성만 표시하고 다른 속성은 숨길 수 있습니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/settings/displayedAttributes' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 0f3cdcfe5d9a56273d6c708f068a82382a97b629b70f4962f969687b5e327196' \
--data-binary '[
"title",
"overview",
"genres",
"release_date"
]'이렇게 하면 쿼리에 포함된 속성만 결과와 함께 표시됩니다.
마지막으로, 필터링하거나 정렬할 속성 목록을 제공할 수 있습니다. 여기에는 < 또는 >와 같은 수학적 연산자를 사용한 정량적 필터링과 지정된 집합에 포함된 필터링이 포함됩니다. 이를 패싯 검색이라고도 합니다.
$ curl \
-X PATCH 'http://localhost:7700/indexes/movies/settings' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 0f3cdcfe5d9a56273d6c708f068a82382a97b629b70f4962f969687b5e327196' \
--data-binary '{
"filterableAttributes": [
"genres",
"release_date"
],
"sortableAttributes": [
"release_date"
]
}'이 모든 규칙을 결합하여 다음과 같은 쿼리를 수행할 수 있습니다.
$ curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer 591e51d2f6700ead7ba134a7aed0966d72e2022e43847caf48df3e4800c9279a' \
--data-binary '{ "q": "house", "sort": ["release_date:desc"], "filter": "genres = Horror" }' | jq여기서는 제목에 house라는 단어가 포함된 최신 영화 중 공포 장르의 모든 영화를 찾고 있습니다. 유사한 출력을 받아야 합니다.
{
"hits": [
{
"id": 440559,
"title": "Housesitters",
"overview": "Angie and Izzy get a housesitting gig that seems too good to be true. Gruesome supernatural hijinks ensue.",
"genres": [
"Comedy",
"Horror"
],
"poster": "https://image.tmdb.org/t/p/w500/9Gnu0PBdYzyd7ZkO74XK0xCH0iY.jpg",
"release_date": 1524873600
},
{
"id": 449550,
"title": "Housewife",
"overview": "Housewife is centered on Holly whose mother murdered her sister and father when she was seven. 20 years later and slowly losing her grip on the difference between reality and nightmares, she runs into a celebrity psychic who claims that he is destined to help her.",
"genres": [
"Horror"
],
"poster": "https://image.tmdb.org/t/p/w500/ohHxS7PIRQb9O6KTrDtqYshYGts.jpg",
"release_date": 1504828800
},
{
"id": 392703,
"title": "House of Darkness",
"overview": "Inspired by true events, the supernatural thriller \"House of Darkness\" recounts the mysterious case of a San Francisco family who claimed that a dark force was responsible for the tragic events that unfolded. Trying to save their struggling marriage Kelly (Sara Fletcher, \"Adulthood\"), her husband Brian (Gunner Wright, \"J. Edgar\") and their daughter Sarah (Mykayla Sohn, \"The Chosen\") move to a rural farmhouse in search of some serenity. Unbeknownst to them, nearly every family that has lived in the house has suffered some form of tragedy, dating back nearly 100 years. Shortly after their arrival, Kelly begins to sense that her husband’s behavior is growing increasingly strange and violent. Kelly also comes to discover the voices she’s hearing echoing through the halls, are not coming from her daughter. Will Kelly and her family be the next victims of the dark forces in the house?",
"genres": [
"Horror",
"Thriller",
"TV Movie"
],
"poster": "https://image.tmdb.org/t/p/w500/ueQM9RsT0HLL2RuuiLmD07j8lKB.jpg",
"release_date": 1460851200
},
…14단계 - 결론
Debian 12 서버에서 프로덕션 환경으로 Meilisearch를 설치하고 구성하는 작업을 완료했습니다. 기본 검색을 수행하고 순위 및 필터링을 통해 검색 결과를 개선하는 방법도 배웠습니다. 질문이 있으면 아래 댓글로 남겨주세요.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.