Linux安装Manticore Search
=======================
### 安装并启动 Manticore
你可以在各种操作系统上轻松安装和启动 Manticore,包括 Ubuntu、Centos、Debian、Windows 和 MacOS。此外,还能使用docker安装,这里演示一下在centos7如何安装Manticore
sudo yum install https://repo.manticoresearch.com/manticore-repo.noarch.rpm
sudo yum install manticore manticore-columnar-lib
sudo systemctl start manticore
连接到 Manticore
默认情况下,Manticore 正在等待您的连接:
- 9306端口用于MySQL客户
- 9308端口用于HTTP/HTTPS连接
- 9312端口用于来自其他 Manticore 节点和基于 Manticore 二进制 API 的客户端的连接
可以在当前机器上直接使用mysql -h0 -P9306
进行连接
使用dbeaver连接
因为我的Manticore是安装在虚拟机里的,用dbeaver进行连接的话需要修改一下配置文件,配置文件的地址默认在 /etc/manticoresearch/manticore.conf
这里需要将监听的ip由127.0.0.1改成0.0.0.0,不然会连接不上,同时要加上 mysql_version_string = 5.0.37
,不然连接的时候可能会有问题,然后在dbeaver新建一个mysql连接就能连接上了,这里不需要用户名和密码。
创建一个表
现在让我们创建一个名为“products”的表,其中包含 2 个字段:
- title – 全文字段将包含我们产品的标题
- prive – float类型
create table products(title text, price float) morphology='stem_en';
Query OK, 0 rows affected (0.02 sec)
添加文档
现在让我们向表中添加一些文档:
insert into products(title,price) values ('Crossbody Bag with Tassel', 19.85), ('microfiber sheet set', 19.99), ('Pet Hair Remover Glove', 7.99);
Query OK, 3 rows affected (0.01 sec)
搜索
让我们找到其中一个文档。我们将使用的查询是“remove hair”。正如你所看到的,它找到一个标题为“Pet Hair Remover Glove”的文档,并在其中突出显示“Hair remover”,即使查询是“remove”,而不是“remover”。这是因为我们创建表的时候启用了English stemming ( morphology "stem_en"
)。
select id, highlight(), price from products where match('remove hair');
更新
假设我们现在想要更新文档 – 将价格更改为 18.5。这可以通过按任何字段过滤来完成,但通常你知道文档 ID 并根据该 ID 更新某些内容。
update products set price=18.5 where id = 7856929107701923843;
删除
现在让我们删除所有价格低于 10 的文档。
delete from products where price < 10;
原文链接: https://juejin.cn/post/7364448176574693427
文章收集整理于网络,请勿商用,仅供个人学习使用,如有侵权,请联系作者删除,如若转载,请注明出处:http://www.cxyroad.com/17990.html