ZincSearch轻量级全文搜索引擎入门到
Zinc是一个用于对文档进行全文搜索的搜索引擎。它是开源的,内置在 Go 中。Zinc不是从头开始构建索引引擎,而是构建在 bluge 之上,这是一个出色的索引库。ZincSearch特点:
- 无模式索引
- 资源利用率低
- 易于使用的轻量级 GUI
- 内置身份验证
- 用于编程使用的简单 API
- 与希望从 Elasticsearch 迁移到 Zinc 的应用程序兼容的 Elasticsearch API(摄取 - 单记录和批量 API)。
2022年5月31日,已经实现基本搜索和API了,集群高可用分布式等等还在开发中。
github:https://github.com/zinclabs/zinc
官网:https://zincsearch.com/
安装
下载window版的易于上手: https://github.com/zinclabs/zinc/releases
set ZINC_FIRST_ADMIN_USER=admin
set ZINC_FIRST_ADMIN_PASSWORD=admin
mkdir data
zinc.exe
登录
然后根据上面设置的密码登录 :http://localhost:4080/
创建一个索引
默认设置
映射内容,,,类似表中的列
创建索引也可以参照按官方的来
e.g. PUT http://localhost:4080/api/index
Request Body:
{"name": "web","storage_type": "disk","settings": {},"mappings": {"properties": {"@timestamp": {"type": "date","index": true,"store": false,"sortable": true,"aggregatable": true,"highlightable": false,"term_positions": false},"_id": {"type": "keyword","index": true,"store": false,"sortable": true,"aggregatable": true,"highlightable": false,"term_positions": false},"content": {"type": "text","index": true,"store": true,"sortable": false,"aggregatable": true,"highlightable": true,"term_positions": true},"title": {"type": "text","index": true,"store": true,"sortable": false,"aggregatable": false,"highlightable": true,"term_positions": true}}}
}
Default storage_type is disk
添加数据和搜索
调用API时必须添加请求头
Authorization: Basic base64(“userId:password”)
YWRtaW46YWRtaW4=
Authorization: Basic YWRtaW46YWRtaW4=
添加数据
一定要发送json格式数据!
{"title": "俄军攻入北顿涅茨克市中心","create_time": "2022-05-31 12:29:55","content": "北顿涅茨克之战打了好几天,乌军承认现在处于劣势。据美国有线电视新闻网报道,乌方的卢甘斯克地区负责人30日表示,俄罗斯军队正在向北顿涅茨克市中心推进。此前俄军已经巩固了对该市东北部和东南部郊区的控制,并试图包围北顿涅茨克和利西昌斯克。“目前战斗非常激烈,”乌方的这名负责人表示,当地情况非常困难,除了通过星链进行权限有限的连接外,该市已经没有互联网连接。"
}
搜索
{"search_type": "querystring","query": {"term": "乌"},"from": 0,"max_results": 20,"_source": ["content"] // 数组为 [] 时,显示所有的块(列)
}