快速入门指南

安装并启动 Manticore

您可以轻松地在各种操作系统上安装和启动 Manticore,包括 Ubuntu、Centos、Debian、Windows 和 MacOS。此外,您还可以将 Manticore 作为 Docker 容器使用。

‹›
  • Ubuntu
  • Debian
  • Centos
  • Windows
  • MacOS
  • Docker
📋
wget https://repo.manticoresearch.com/manticore-repo.noarch.deb
sudo dpkg -i manticore-repo.noarch.deb
sudo apt update
sudo apt install manticore manticore-columnar-lib
sudo systemctl start manticore

连接到 Manticore

默认情况下,Manticore 等待您的连接端口为:

  • 端口 9306 用于 MySQL 客户端
  • 端口 9308 用于 HTTP/HTTPS 连接
  • 端口 9312 用于来自其他 Manticore 节点和基于 Manticore 二进制 API 的客户端的连接

有关 HTTPS 支持的更多详细信息,请参阅我们的学习课程这里

‹›
  • SQL
  • HTTP
  • PHP
  • Python
  • Python-asyncio
  • Javascript
  • Java
  • C#
  • Rust
  • Typescript
  • Go
📋
mysql -h0 -P9306

创建表

现在让我们创建一个名为 "products" 的表,包含 2 个字段:

  • title - 全文字段,将包含我们产品的标题
  • price - 类型为 "float"

请注意,可以省略使用显式创建语句创建表。更多信息请参见自动模式

有关创建表的不同方式的更多信息,请参阅我们的学习课程:

‹›
  • SQL
  • HTTP
  • PHP
  • Python
  • Python-asyncio
  • Javascript
  • Java
  • C#
  • Rust
  • TypeScript
  • Go
📋
create table products(title text, price float) morphology='stem_en';
‹›
Response
Query OK, 0 rows affected (0.02 sec)

添加文档

现在让我们向表中添加一些文档:

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • Javascript
  • Java
  • C#
  • Rust
  • TypeScript
  • Go
📋
insert into products(title,price) values ('Crossbody Bag with Tassel', 19.85), ('microfiber sheet set', 19.99), ('Pet Hair Remover Glove', 7.99);
‹›
Response
Query OK, 3 rows affected (0.01 sec)

更多关于该主题的详细信息请参见:

搜索

让我们查找其中一份文档。我们将使用的查询是“remove hair”。如您所见,它找到了标题为“Pet Hair Remover Glove”的文档,并且高亮显示了其中的“Hair remover”,即使查询中是“remove”,而不是“remover”。这是因为在创建表时,我们启用了英文词干处理(morphology "stem_en")。

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • TypeScript
  • Go
📋
select id, highlight(), price from products where match('remove hair');
‹›
Response
+---------------------+-------------------------------+----------+
| id                  | highlight()                   | price    |
+---------------------+-------------------------------+----------+
| 1513686608316989452 | Pet <b>Hair Remover</b> Glove | 7.990000 |
+---------------------+-------------------------------+----------+
1 row in set (0.00 sec)

关于 Manticore 中可用的不同搜索选项的更多信息,请参见我们的学习课程:

更新

假设我们现在想更新文档——将价格改为18.5。可以通过任何字段进行过滤,但通常您知道文档ID,并基于此进行更新。

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • TypeScript
  • Go
📋
update products set price=18.5 where id = 1513686608316989452;
‹›
Response
Query OK, 1 row affected (0.00 sec)

删除

现在让我们删除所有价格低于10的文档。

‹›
  • SQL
  • JSON
  • PHP
  • Python
  • Python-asyncio
  • javascript
  • Java
  • C#
  • Rust
  • TypeScript
  • Go
📋
delete from products where price < 10;
‹›
Response
Query OK, 1 row affected (0.00 sec)
Last modified: August 28, 2025