From 9f7a33a95bb3bd268c0c365f9f476ea0dce40ec9 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Tue, 15 Apr 2025 13:55:55 +0800 Subject: [PATCH 1/5] docs: update english --- docs/plugins/search/meilisearch.md | 211 ++++++++++++++++++++++------- 1 file changed, 161 insertions(+), 50 deletions(-) diff --git a/docs/plugins/search/meilisearch.md b/docs/plugins/search/meilisearch.md index bab0fbdc26..01e9218aa7 100644 --- a/docs/plugins/search/meilisearch.md +++ b/docs/plugins/search/meilisearch.md @@ -8,57 +8,86 @@ icon: https://www.meilisearch.com/favicon.ico Integrate [MeiliSearch](https://www.meilisearch.com/) into VuePress, which can provide search to your documentation site. -## Usage +## Setup MeiliSearch -```bash -npm i -D @vuepress/plugin-meilisearch@next -``` +To use MeiliSearch for free, you need to self-host it on your own server, otherwise you need to pay for MeiliSearch Cloud. -```ts -import { MeiliSearchPlugin } from '@vuepress/plugin-meilisearch' +::: info MeiliSearch Cloud -export default { - plugins: [ - meilisearchPlugin({ - // Configuration options - host: '', - apiKey: '', - indexUid: '', - }), - ], -} -``` +To use MeiliSearch Cloud, you need to create an account and set up a new instance. You can find the instructions in the [MeiliSearch Cloud documentation](https://www.meilisearch.com/docs/cloud/getting_started). + +::: + +### Starting MeiliSearch + +::: tip -## Self-hosting MeiliSearch +In this section, we use Docker to self-host Meilisearch, see [MeiliSearch Docker docs](https://www.meilisearch.com/docs/guides/misc/docker) for details. -MeiliSearch provides a server program that supports self-deployment options for users with cloud servers. To simplify the process of running MeiliSearch on the server side, you can use Docker for installation and management. +If you don't have Docker installed, you may also [install MeiliSearch manually](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch#setup-and-installation). + +::: + +First pull latest MeiliSearch docker image: ```sh docker pull getmeili/meilisearch:latest ``` -On the first startup, a Master Key will be generated by default. **Do not expose this key**; it should only be used for internal server access, as it grants full operational permissions. +Then start the docker: -```sh +```sh :no-line-numbers docker run -it --rm \ + # set container name to "MeiliSearch" + --name MeiliSearch \ + # set your own master key + # replace with your own master key + -e MEILI_MASTER_KEY='' \ + # switch to production mode + -e MEILI_ENV=production \ + # disable meilisearch analytics + -e MEILI_NO_ANALYTICS=1 \ + # mapping 7700 port to host -p 7700:7700 \ + # mounting index database to host + # you can change the path to anywhere you want -v $(pwd)/meili_data:/meili_data \ getmeili/meilisearch:latest ``` -> See +Here `` is the master key for MeiliSearch, which is used to access the MeiliSearch API (required >= 16 bytes). -## Crawling the website +::: important Never expose Master Key -MeiliSearch provides a Docker crawler to crawl documents. Until then, make sure MeiliSearch is running. +Search key can be generated for public access, which only allows search operations. -Here is a sample of crawler configuration, which you should save, modify and pass to the crawler: +Your Master Key should only be used for internal server access (including scraping), as it grants full operational permissions. Do not mix use them and **never expose this key**! -```json +::: + +## Setting up the Scraper + +::: tip + +MeiliSearch provides a Docker Scraper image to scrape your documents. for details, see [meilisearch: scrape your content](https://www.meilisearch.com/docs/guides/front_end/search_bar_for_docs#scrape-your-content). + +If you don't have docker installed, you can [run scraper from source code](https://github.com/meilisearch/docs-scraper?tab=readme-ov-file#from-source-code-). + +::: + +First, pull the latest MeiliSearch Scraper image: + +```sh +docker pull getmeili/docs-scraper:latest +``` + +Then, create a **correct configuration file** for the scraper. Here, we provide a sample, which you should save it locally and modify according to your needs: + +```json :collapsed-lines=10 { - "index_uid": "YOUR_INDEX_NAME", - "start_urls": ["https://YOUR_WEBSITE_URL/"], - "sitemap_urls": ["https://YOUR_WEBSITE_URL/sitemap.xml"], + "index_uid": "", + "start_urls": ["https:///"], + "sitemap_urls": ["https:///sitemap.xml"], "selectors": { "lvl0": { "selector": ".vp-sidebar-heading.active", @@ -125,11 +154,12 @@ Here is a sample of crawler configuration, which you should save, modify and pas } ``` -- `start_urls` and `sitemap_urls` (optional) shall be customized according to the website to be crawled. +- `index_uid` should be a unique name for your index, which will be used to search. +- `start_urls` and `sitemap_urls` (optional) shall be customized according to the website to be scraped. - `selectors` field can be customized according to third-party theme DOM structure. - You can add new fields to `custom_settings` according to your needs. -::: important +::: important Requirements for the configuration file To let the plugin work: @@ -138,64 +168,141 @@ To let the plugin work: ::: -Start scraping the document, `MEILISEARCH_HOST_URL` is the address of the host running MeiliSearch, `` is the master key, `` is the absolute path to fetch the configuration file: +Make sure MeiliSearch is currently running, then start scraping the document by running the docker: ```sh docker run -t --rm \ --network=host \ -e MEILISEARCH_HOST_URL='' \ - -e MEILISEARCH_API_KEY='' \ + -e MEILISEARCH_API_KEY='' \ -v :/docs-scraper/config.json \ getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json ``` -When the crawl is complete, MeiliSearch stores the crawled document in the specified index. +Here: -> See +- `` should be the host URL of your MeiliSearch instance +- `` shall be the master key you provided. +- `` is the absolute path to the configuration file you created above. -## Get search index and api key +When the scraper completes, MeiliSearch will update the existing index with latest document content. -To create an access key that only allows search operations, use the following request. The `indexes` array specifies which indexes this key can access, and `expiresAt` sets the key's expiration date. +### Setting up the Plugin + +A search-only access key shall be generated for the plugin to work. This key can be generated using the MeiliSearch API. +You can use the following command to create a search-only access key: ```sh curl \ - -X POST 'http://localhost:7700/keys' \ + # Replace with your MeiliSearch host URL + -X POST '/keys' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ + # description f --data-binary '{ - "description": "Search records key", + "indexes": [""], "actions": ["search"], - "indexes": ["YOUR_INDEX_NAME"], - "expiresAt": "2025-01-01T00:00:00Z" + "expiresAt": null, + "description": "Search key for " }' ``` +Here: + +- `` is the host URL of your MeiliSearch instance +- `` is the master key generated by MeiliSearch +- `` is the name of the index you created +- `actions` specifies the actions that this key can perform. In this case, it is set to `["search"]`, which means it can only perform search operations. +- `expiresAt` sets the expiration date for the key, allowing you to control how long the key remains valid, `null` means it will never expire. + If successful, the response would look like this: ```json { "name": null, - "description": "Search records key", + "description": "Search key for ", "key": "adaf72e2a6d6f428ec465bc786ec41de868bbd53121997e89ba2299e9566c88213", "uid": "b84d1be5-caa5-4752-b078-8f40be39051d", "actions": ["search"], - "indexes": ["YOUR_INDEX_NAME"], - "expiresAt": "2025-01-01T00:00:00Z", + "indexes": [""], + "expiresAt": "null", "createdAt": "2024-01-27T06:50:33.668329328Z", "updatedAt": "2024-01-27T06:50:33.668329328Z" } ``` -This key can be exposed and used externally as needed. Enter it in your plugin options. +Now, you can use the `key` in the plugin configuration. Install the plugin in your VuePress project and then provide required options: + +```bash +npm i -D @vuepress/plugin-meilisearch@next +``` ```ts -meilisearchPlugin({ - host: 'YOUR_HOST', - apiKey: 'adaf72e2a6d6f428ec465bc786ec41de868bbd53121997e89ba2299e9566c88213', - indexUid: 'YOUR_INDEX_NAME', -}) +import { meiliSearchPlugin } from '@vuepress/plugin-meilisearch' + +export default { + plugins: [ + meilisearchPlugin({ + host: '', + apiKey: '', + indexUid: '', + }), + ], +} ``` +### Automatic Re-scraping with Github Actions + +Place your scraper config file somewhere in your project. + +Then go to `Settings` -> `Secrets and variables` -> `Actions` in your Github repository. Click `New repository secret` and set `MEILISEARCH_MASTER_KEY` with your meilisearch master key. + +Next add a new step `scrape` in your Github Actions workflow file, which will run after the deployment step. Here is an example of how to do this: + +```yml +name: Deploy and Scrape + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + # deploy your documentation here + # ... + + scrape: + needs: deploy + runs-on: ubuntu-latest + name: re-scrape documentation for Meilisearch + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run scraper + env: + # replace with your own MeiliSearch host URL + HOST_URL: + API_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }} + # replace it with the path to your config file + CONFIG_FILE_PATH: ${{ github.workspace }}/ + run: | + docker run -t --rm \ + -e MEILISEARCH_HOST_URL=$HOST_URL \ + -e MEILISEARCH_API_KEY=$API_KEY \ + -v $CONFIG_FILE_PATH:/docs-scraper/config.json \ + getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json +``` + +::: tip Key for Scraper + +To secure your MeiliSearch instance, you can create a new key with limited permissions for the scraper. Similar to search key above, this key should only have access to the `index` and `documents` actions. + +::: + ## Options ### host @@ -272,3 +379,7 @@ meilisearchPlugin({ ## Components - SearchBox + +``` + +``` From e2cf95ce1f6bf60befb7747c3c5421e2079f9dbe Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Tue, 15 Apr 2025 13:57:14 +0800 Subject: [PATCH 2/5] docs: tweaks --- docs/plugins/search/meilisearch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins/search/meilisearch.md b/docs/plugins/search/meilisearch.md index 01e9218aa7..d6ad10ae8a 100644 --- a/docs/plugins/search/meilisearch.md +++ b/docs/plugins/search/meilisearch.md @@ -65,7 +65,7 @@ Your Master Key should only be used for internal server access (including scrapi ::: -## Setting up the Scraper +### Setting up the Scraper ::: tip From 9bf30b9a6337af9e85ab99d5c86da628db836773 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Tue, 15 Apr 2025 14:01:32 +0800 Subject: [PATCH 3/5] chore: tweaks --- docs/plugins/search/meilisearch.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/plugins/search/meilisearch.md b/docs/plugins/search/meilisearch.md index d6ad10ae8a..0bf4f8c034 100644 --- a/docs/plugins/search/meilisearch.md +++ b/docs/plugins/search/meilisearch.md @@ -379,7 +379,3 @@ To secure your MeiliSearch instance, you can create a new key with limited permi ## Components - SearchBox - -``` - -``` From 189634e921f78b04c8b3a95504d8dc30dd1d54ad Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Tue, 15 Apr 2025 14:04:33 +0800 Subject: [PATCH 4/5] chore: tweaks --- docs/plugins/search/meilisearch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins/search/meilisearch.md b/docs/plugins/search/meilisearch.md index 0bf4f8c034..fdd3414d56 100644 --- a/docs/plugins/search/meilisearch.md +++ b/docs/plugins/search/meilisearch.md @@ -225,7 +225,7 @@ If successful, the response would look like this: "uid": "b84d1be5-caa5-4752-b078-8f40be39051d", "actions": ["search"], "indexes": [""], - "expiresAt": "null", + "expiresAt": null, "createdAt": "2024-01-27T06:50:33.668329328Z", "updatedAt": "2024-01-27T06:50:33.668329328Z" } From 06d8f89b73320b57900d23cdecc311fc197a47e8 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Tue, 15 Apr 2025 14:13:10 +0800 Subject: [PATCH 5/5] docs: update docs --- docs/plugins/search/meilisearch.md | 8 +- docs/zh/plugins/search/meilisearch.md | 213 +++++++++++++++++++------- 2 files changed, 164 insertions(+), 57 deletions(-) diff --git a/docs/plugins/search/meilisearch.md b/docs/plugins/search/meilisearch.md index fdd3414d56..4f9ae10e7f 100644 --- a/docs/plugins/search/meilisearch.md +++ b/docs/plugins/search/meilisearch.md @@ -55,7 +55,7 @@ docker run -it --rm \ getmeili/meilisearch:latest ``` -Here `` is the master key for MeiliSearch, which is used to access the MeiliSearch API (required >= 16 bytes). +Here `` is the master key for MeiliSearch that you should set yourself (required >= 16 bytes), which is used to access the MeiliSearch API. ::: important Never expose Master Key @@ -69,9 +69,9 @@ Your Master Key should only be used for internal server access (including scrapi ::: tip -MeiliSearch provides a Docker Scraper image to scrape your documents. for details, see [meilisearch: scrape your content](https://www.meilisearch.com/docs/guides/front_end/search_bar_for_docs#scrape-your-content). +MeiliSearch provides a Docker Scraper image to scrape your documents. for details, see [MeiliSearch: scrape your content](https://www.meilisearch.com/docs/guides/front_end/search_bar_for_docs#scrape-your-content). -If you don't have docker installed, you can [run scraper from source code](https://github.com/meilisearch/docs-scraper?tab=readme-ov-file#from-source-code-). +If you don't have Docker installed, you can [run scraper from source code](https://github.com/meilisearch/docs-scraper?tab=readme-ov-file#from-source-code-). ::: @@ -299,7 +299,7 @@ jobs: ::: tip Key for Scraper -To secure your MeiliSearch instance, you can create a new key with limited permissions for the scraper. Similar to search key above, this key should only have access to the `index` and `documents` actions. +To secure your MeiliSearch instance, you can create a new key with limited permissions for the scraper. Similar to search key above, this key should only have access to these actions: `["indexes.create","indexes.delete","settings.update","documents.add"]` ::: diff --git a/docs/zh/plugins/search/meilisearch.md b/docs/zh/plugins/search/meilisearch.md index 511d54fae8..17cab19e56 100644 --- a/docs/zh/plugins/search/meilisearch.md +++ b/docs/zh/plugins/search/meilisearch.md @@ -8,57 +8,86 @@ icon: https://www.meilisearch.com/favicon.ico 将 [MeiliSearch](https://www.meilisearch.com/) 集成到 VuePress 中,为你的文档网站提供搜索功能。 -## 使用方法 +## 安装 MeiliSearch -```bash -npm i -D @vuepress/plugin-meilisearch@next -``` +要免费使用 MeiliSearch,你需要在自己的服务器上自托管它,否则需要付费使用 MeiliSearch Cloud。 -```ts -import { meilisearchPlugin } from '@vuepress/plugin-meilisearch' +::: info MeiliSearch Cloud -export default { - plugins: [ - meilisearchPlugin({ - // 配置项 - host: '', - apiKey: '', - indexUid: '', - }), - ], -} -``` +要使用 MeiliSearch Cloud,请创建一个账户并设置新的实例。你可以在 [MeiliSearch Cloud 文档](https://www.meilisearch.com/docs/cloud/getting_started) 中找到说明。 + +::: + +### 启动 MeiliSearch -## 在服务器上运行 MeiliSearch +::: tip -MeiliSearch 提供了一个服务器程序,支持使用云服务器的用户的自部署选项。为了简化在服务器端运行 MeiliSearch 的过程,你可以使用 Docker 进行安装和管理。 +在本节中,我们使用 Docker 来自托管 MeiliSearch,请参阅 [MeiliSearch Docker 文档](https://www.meilisearch.com/docs/guides/misc/docker) 以获取详细信息。 + +如果你尚未安装 Docker,也可以 [手动安装 MeiliSearch](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch#setup-and-installation)。 + +::: + +首先拉取最新的 MeiliSearch Docker 镜像: ```sh docker pull getmeili/meilisearch:latest ``` -在第一次启动时,默认情况下将生成一个主密钥(MASTER_KEY)。**不要暴露此密钥**;它应该只用于内部服务器访问,因为它拥有完全的操作权限。 +然后启动容器: -```sh +```sh :no-line-numbers docker run -it --rm \ + # 将容器名称设置为 "MeiliSearch" + --name MeiliSearch \ + # 设置你自己的主密钥 + # 替换 为你自己的主密钥 + -e MEILI_MASTER_KEY='' \ + # 切换到生产模式 + -e MEILI_ENV=production \ + # 禁用 MeiliSearch 分析 + -e MEILI_NO_ANALYTICS=1 \ + # 将 7700 端口映射到主机 -p 7700:7700 \ + # 挂载索引数据库到主机 + # 你可以将路径更改为任何位置 -v $(pwd)/meili_data:/meili_data \ getmeili/meilisearch:latest ``` -> 参考 +此处 `` 是你需要自行设置的 MeiliSearch 主密钥(需 >= 16 字节),用于访问 MeiliSearch API。 -## 抓取网站 +::: 重要 不要暴露主密钥 -MeiliSearch 提供了一个 Docker 爬虫来抓取文档。在此之前,保证 MeiliSearch 已经运行。 +搜索密钥可以生成供公共访问,仅允许执行搜索操作。 -这是一个爬虫配置的示例,你应该保存、修改并传递给爬虫: +你的主密钥应仅用于内部服务器访问(包括抓取),因为它授予完整的操作权限。不要混用它们,并且 **绝不要暴露此密钥**! -```json +::: + +### 设置抓取器 + +::: tip + +MeiliSearch 提供了一个 Docker 抓取器镜像来抓取你的文档。有关详细信息,请参阅 [MeiliSearch:抓取内容](https://www.meilisearch.com/docs/guides/front_end/search_bar_for_docs#scrape-your-content)。 + +如果你没有安装 Docker,可以 [从源代码运行抓取器](https://github.com/meilisearch/docs-scraper?tab=readme-ov-file#from-source-code-)。 + +::: + +首先,拉取最新的 MeiliSearch 抓取器镜像: + +```sh +docker pull getmeili/docs-scraper:latest +``` + +然后为抓取器创建一个 **正确的配置文件**。这里提供了一个示例,你应将其保存在本地并根据需要进行修改: + +```json :collapsed-lines=10 { - "index_uid": "YOUR_INDEX_NAME", - "start_urls": ["https://YOUR_WEBSITE_URL/"], - "sitemap_urls": ["https://YOUR_WEBSITE_URL/sitemap.xml"], + "index_uid": "", + "start_urls": ["https:///"], + "sitemap_urls": ["https:///sitemap.xml"], "selectors": { "lvl0": { "selector": ".vp-sidebar-heading.active", @@ -125,77 +154,155 @@ MeiliSearch 提供了一个 Docker 爬虫来抓取文档。在此之前,保证 } ``` +- `index_uid` 应为你的索引分配一个唯一名称,用于搜索。 - `start_urls` 和 `sitemap_urls`(可选)应根据要抓取的网站进行自定义。 -- `selectors` 字段可以根据第三方 DOM 结构进行自定义。 -- 你可以根据需要向 `custom_settings` 添加新字段。 +- `selectors` 字段可以根据第三方主题 DOM 结构进行自定义。 +- 你可以根据需要向 `custom_settings` 中添加新字段。 -::: important +::: important 配置文件要求 -为了让插件工作: +为了让插件正常工作: - `lang` 选择器必须在 `selectors` 字段中保持不变 -- `custom_settings` 中当前的所有字段都不能删除。 +- `custom_settings` 中的所有当前字段不得删除。 ::: -开始抓取文档,`MEILISEARCH_HOST_URL` 是运行 MeiliSearch 的主机地址,`` 是主密钥,`` 是抓取配置文件的绝对路径: +确保 MeiliSearch 正在运行,然后通过运行以下 Docker 命令来抓取文档: ```sh docker run -t --rm \ --network=host \ -e MEILISEARCH_HOST_URL='' \ - -e MEILISEARCH_API_KEY='' \ + -e MEILISEARCH_API_KEY='' \ -v :/docs-scraper/config.json \ getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json ``` -抓取完成后,MeiliSearch 将在指定的索引中存储抓取到的文档。 +此处: + +- `` 应为你的 MeiliSearch 实例的主机 URL +- `` 是你提供的主密钥。 +- `` 是你创建的配置文件的绝对路径。 -> 参考 +抓取完成后,MeiliSearch 将更新现有索引以包含最新的文档内容。 -## 获取搜索索引和 API 密钥 +### 设置插件 -要创建只允许搜索操作的访问密钥,请使用以下请求。`indexes` 数组指定该密钥可以访问哪些索引,`expiresAt` 设置密钥的过期时间。 +为了使插件正常工作,需要为插件生成一个仅限搜索的访问密钥。此密钥可以通过 MeiliSearch API 创建。 +你可以使用以下命令创建仅限搜索的访问密钥: ```sh curl \ - -X POST 'http://localhost:7700/keys' \ + # 将 替换为你的 MeiliSearch 主机 URL + -X POST '/keys' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ + # 描述 f --data-binary '{ - "description": "Search records key", + "indexes": [""], "actions": ["search"], - "indexes": ["YOUR_INDEX_NAME"], - "expiresAt": "2025-01-01T00:00:00Z" + "expiresAt": null, + "description": "Search key for " }' ``` +此处: + +- `` 是你的 MeiliSearch 实例的主机 URL +- `` 是 MeiliSearch 生成的主密钥 +- `` 是你创建的索引名称 +- `actions` 指定此密钥可以执行的操作。在此情况下,设置为 `["search"]`,表示它只能执行搜索操作。 +- `expiresAt` 设置密钥的过期日期,允许你控制密钥的有效期限,`null` 表示永远不会过期。 + 如果成功,响应将如下所示: ```json { "name": null, - "description": "Search records key", + "description": "Search key for ", "key": "adaf72e2a6d6f428ec465bc786ec41de868bbd53121997e89ba2299e9566c88213", "uid": "b84d1be5-caa5-4752-b078-8f40be39051d", "actions": ["search"], - "indexes": ["YOUR_INDEX_NAME"], - "expiresAt": "2025-01-01T00:00:00Z", + "indexes": [""], + "expiresAt": null, "createdAt": "2024-01-27T06:50:33.668329328Z", "updatedAt": "2024-01-27T06:50:33.668329328Z" } ``` -该密钥可以根据需要在外部公开和使用,填入到你的插件选项中: +现在,你可以将 `key` 用于插件配置。在你的 VuePress 项目中安装插件并提供所需的选项: + +```bash +npm i -D @vuepress/plugin-meilisearch@next +``` ```ts -meilisearchPlugin({ - host: 'YOUR_HOST', - apiKey: 'adaf72e2a6d6f428ec465bc786ec41de868bbd53121997e89ba2299e9566c88213', - indexUid: 'YOUR_INDEX_NAME', -}) +import { meiliSearchPlugin } from '@vuepress/plugin-meilisearch' + +export default { + plugins: [ + meilisearchPlugin({ + host: '', + apiKey: '', + indexUid: '', + }), + ], +} ``` +### 使用 GitHub Actions 自动重新抓取 + +将你的抓取器配置文件放在项目中的某个位置。 + +然后转到 `Settings` -> `Secrets and variables` -> `Actions` 在你的 GitHub 仓库中。点击 `New repository secret` 并设置 `MEILISEARCH_MASTER_KEY` 为你自己的 MeiliSearch 主密钥。 + +接下来在你的 GitHub Actions 工作流文件中添加一个新的步骤 `scrape`,它将在部署步骤之后运行。以下是操作示例: + +```yml +name: 部署和抓取 + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + # 在此处部署你的文档 + # ... + + scrape: + needs: deploy + runs-on: ubuntu-latest + name: 重新抓取 MeiliSearch 文档 + steps: + - 名称:Checkout + uses: actions/checkout@v4 + + - 名称:运行抓取器 + env: + # 替换为你自己的 MeiliSearch 主机 URL + HOST_URL: + API_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }} + # 替换为配置文件的路径 + CONFIG_FILE_PATH: ${{ github.workspace }}/ + run: | + docker run -t --rm \ + -e MEILISEARCH_HOST_URL=$HOST_URL \ + -e MEILISEARCH_API_KEY=$API_KEY \ + -v $CONFIG_FILE_PATH:/docs-scraper/config.json \ + getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json +``` + +::: tip 抓取器密钥 + +为了保护你的 MeiliSearch 实例,你可以为抓取器创建一个具有有限权限的新密钥。与上面的搜索密钥类似,此密钥应仅对以下操作具有访问权限:`["indexes.create","indexes.delete","settings.update","documents.add"]`。 + +::: + ## 选项 ### host