Import dữ liệu vào Melisearch, build tool cho ARM

Bước 1: Đầu tiên, cài Melisearch bằng docker, rất thận lợi, chú ý thiết lập biến môi trường KEY của Melisearch, thiết lập volumn để lưu dữ liệu khi nâng cấp hoặc xóa docker image.

Bước 2: Tiếp đến import dữ liệu (json hoặc cvs), cấu trúc dữ liệu cần có primary-key. Nên dùng tool viết bằng rust rất tiện meilisearch-importer. Có thể phải build lại tool này vì meilisearch-importer không có bản build chạy trên chip ARM.

Giờ mới tới công chuyện về các lỗi phát sinh.

Index/Import dữ liệu vào Melisearch với tool (Có thể chạy trên local hoặc remote).

./meilisearch-importer \
--url 'http://localhost:7700'\
--index vietnamese_news\
--primary-key id\
--api-key 'gghghghghghghghghghghghghghghghghhg'\
--files news_dataset.json \
--batch-size 90MB

Kết quả nhận được:

2024-11-14T03:01:12.620748Z INFO HTTP request{method=POST host="localhost:7700" route=/indexes/vietnamese_news/documents query_parameters=primaryKey=id user_agent=ureq/2.9.6 status_code=413 error=The provided payload reached the size limit. The maximum accepted payload size is 95.367431640625 MiB.}: meilisearch: close time.busy=76.8ms time.idle=456ms

Nguyên nhân là mặc định Melisearch chỉ nhận tối đa 100 MB. Cách sửa: đổi cấu hình.

Lỗi payload mặc định 100 MB (file tối đa mặc định)

Environment variableMEILI_HTTP_PAYLOAD_SIZE_LIMIT
CLI option--http-payload-size-limit
Default value104857600 (~100MB)
Expected value: an integer

Sets the maximum size of accepted payloads. Value must be given in bytes or explicitly stating a base unit. For example, the default value can be written as 107374182400'107.7Gb', or '107374 Mb'.

Import bằng json cho remote server rất nhanh và thuận lợi.

Đây là tính năng rất xịn nghệ.

https://www.meilisearch.com/docs/learn/self_hosted/configure_meilisearch_at_launch#payload-limit-size

Leave a Comment