当前位置: 首页 > news >正文

知识库搭建之Meilisearch‘s 搜索引擎 测评-东方仙盟测评师

windows 启动后

 

 

启动成功后关键信息

Config file path:       "none"
Database path:          "./data.ms"
Server listening on:    "http://localhost:7700"
Environment:            "development"
Commit SHA:             "0312fb22b8e660c939eaa24ebe44bae8e9e68b6a"
Commit date:            "2025-07-17T15:57:39Z"
Package version:        "1.16.0"

 浏览器访问http://127.0.0.1:7700/

建立本地数据库

Meilisearch 建立本地知识库主要包括安装启动、创建索引、添加文档等步骤,以下是详细操作过程:

  1. 安装 Meilisearch
    • 使用 Docker 安装(推荐):打开终端,运行命令docker pull getmeili/meilisearch:latest拉取最新的 Meilisearch 镜像。然后运行docker run -it --rm -p 7700:7700 -v d:/work/meilisearch/:/ getmeili/meilisearch:latest启动 Meilisearch 容器,其中-p 7700:7700将容器的 7700 端口映射到本地的 7700 端口,-v d:/work/meilisearch/:/用于挂载数据卷,可根据需要修改为合适的本地路径。
    • 使用 Homebrew 安装(适用于 Mac):运行brew update && brew install meilisearch命令更新 Homebrew 并安装 Meilisearch。安装完成后,可以使用meilisearch --master-key={MASTER_KEY} --env production命令启动 Meilisearch,其中{MASTER_KEY}需替换为你设置的主密钥,--env production表示以生产模式启动,若不传递此参数,默认为开发模式。
  2. 访问管理界面:启动成功后,打开浏览器,访问http://localhost:7700,可以看到 Meilisearch 自带的调试界面,用于后续的操作和调试。
  3. 创建索引:Meilisearch 中的索引类似于数据库中的表,用于存储文档。你可以通过 API 或使用相应的 SDK 来创建索引。例如,使用 PHP SDK 时,代码如下:

php

require_once __DIR__ . '/vendor/autoload.php';
use MeiliSearch\Client;
$client = new Client('http://localhost:7700');
$index = $client->index('your_index_name');

其中your_index_name需替换为你想要创建的索引名称。如果索引不存在,Meilisearch 会在第一次添加文档时自动创建它。
4. 准备文档数据:收集并整理你要添加到知识库的文档数据,确保数据格式符合 Meilisearch 的要求。通常文档数据应为 JSON 格式的数组,每个元素是一个文档对象,文档对象中的字段名和字段值通过键值对的形式进行存储。例如:

json

[{"id": 1, "title": "Document 1", "content": "This is the content of document 1."},{"id": 2, "title": "Document 2", "content": "This is the content of document 2."}
]

这里的id字段通常作为主键,用于唯一标识每个文档。
5. 添加文档到索引:使用 API 或 SDK 将准备好的文档数据添加到创建好的索引中。继续以 PHP SDK 为例,代码如下:

php

$documents = [{"id": 1, "title": "Document 1", "content": "This is the content of document 1."},{"id": 2, "title": "Document 2", "content": "This is the content of document 2."}
];
$index->addDocuments($documents);

执行上述代码后,Meilisearch 会对文档进行索引处理,使其可被搜索。
6. 搜索测试:回到 Meilisearch 的管理界面http://localhost:7700,在搜索框中输入关键词,测试是否能够正确搜索到添加的文档。也可以通过 API 或 SDK 编写搜索代码来进行测试。

阿雪技术观


在科技发展浪潮中,我们不妨积极投身技术共享。不满足于做受益者,更要主动担当贡献者。无论是分享代码、撰写技术博客,还是参与开源项目维护改进,每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地,我们携手在此探索硅基生命,为科技进步添砖加瓦。

Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology.  

http://www.lryc.cn/news/595889.html

相关文章:

  • STL学习(一、string容器)
  • 暑假算法训练.6
  • 深入浅出Python函数:参数传递、作用域与案例详解
  • 根据数据,判断神经网络所需的最小参数量
  • 设计模式七:抽象工厂模式(Abstract Factory Pattern)
  • 【Linux内核模块】模块声明与描述
  • 【RK3576】【Android14】MIC开发调试
  • 杭州网站建设选哪家?派迪科技项目实力展示
  • Python 正则表达式在数据分析中的应用:实战指南
  • OpenCV基本的图像处理
  • AI助力临床医学科研创新与效率双提升丨临床医学日常工作、论文高效撰写与项目申报、数据分析与可视化、机器学习建模等
  • 深入解析 Pandas:Python 数据分析的强大工具
  • AWE2026启动:加码AI科技,双展区联动开启产业新格局
  • 小玩 Lifecycle
  • ESP32-Cam三脚架机器人:DIY你的智能移动监控平台
  • 单一职责原则(SRP):构建高质量软件的基石
  • 【接口自动化】掌握接口自动化:核心概念讲解(理论知识)
  • Java 大视界 -- Java 大数据在智能医疗医疗设备维护与管理中的应用(358)
  • 阁楼式货架:垂直空间革命下的仓储效率升级方案
  • 在线教育培训课程视频如何防下载、防盗录?
  • 企业级IIS配置手册:安全加固/负载均衡/性能优化最佳实践
  • 为什么使用扩展坞会降低显示器的最大分辨率和刷新率
  • Cloud 与 VPS 的区别:如何选择最适合你的服务器解决方案?
  • vmware vsphere esxi6.5 使用工具导出镜像
  • SecretFlow (3) --- 添加合作方并创建项目
  • python小工具:测内网服务器网速和延迟
  • IPv4枯竭时代:从NAT技术到IPv6的演进之路
  • 本地代理和服务器代理区别
  • 目标检测系列(六)labelstudio实现自动化标注
  • JVM:工具