终于有Go版的Elasticsearch了请联系polarisxu公众号转载本文。大家好,我是polarisxu。Solr和Elasticsearch通常用于在企业内部构建搜索引擎。都是用Java实现的,底层依赖Lucene。Java占用的内存相对较多。今天要介绍的项目旨在替代ES,一个轻量级的搜索引擎:Zinc。项目地址:https://github.com/prabhatsharma/zinc,项目开源十多天,目前有3.4k+stars。Zinc是一个全文索引搜索引擎。它是Elasticsearch的轻量级替代品,可以在不到100MB的RAM中运行。它使用blage作为底层索引库。此外,Zinc使用Vue来创建比Elasticsearch更简单、更用户友好的界面。如果您只是使用API获取数据并使用kibana进行搜索(Kibana不支持Zinc。Zinc提供自己的UI),则zinc是Elasticsearch的直接替代品。Zinc主要有以下特点:提供全文索引功能单个二进制文件即可安装运行,支持多平台。这要归功于用于查询数据的WebUI使用Go语言编写的Vue兼容Elasticsearch的数据获取API(单记录和批量API)开箱即用的身份验证Schemaless-无需预先定义schema,同一个索引不同的文档可以有不同的字段,但是目前Zinc还处于alpha阶段,缺乏聚类,可用性没有得到很好的验证。关于如何安装和使用,项目主页有说明,支持普通安装(可以直接下载编译好的二进制文件),也支持Docker和K8S的安装和使用。我按照说明在本地建了索引:$FIRST_ADMIN_USER=adminFIRST_ADMIN_PASSWORD=Complexpass#123./zinc{"level":"debug","time":"2021-12-12T22:53:51+08:00","message":"Loadingindexes..."}{"level":"debug","time":"2021-12-12T22:53:51+08:00","message":"Loadingsystemindexes..."}{"level":"debug","time":"2021-12-12T22:53:51+08:00","message":"Indexloaded:_users"}{"level":"debug","time":"2021-12-12T22:53:51+08:00","message":"Indexloaded:_index_mapping"}{"level":"debug","time":"2021-12-12T22:53:51+08:00","message":"Errorloading.envfile"}[GIN-debug][警告]在“调试”模式下运行。在生产中切换到“发布”模式。-usingenv:exportGIN_MODE=release-usingcode:gin.SetMode(gin.ReleaseMode)[GIN-debug]GET/healthz-->github.com/prabhatsharma/zinc/pkg/meta/v1.GetHealthz(3handlers)[GIN-debug]GET/-->github.com/prabhatsharma/zinc/pkg/meta/v1.GUI(3handlers)[GIN-debug]GET/ui/*filepath-->github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1(3handlers)[GIN-debug]HEAD/ui/*filepath-->github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1(3handlers)[GIN-debug]POST/api/login-->github.com/prabhatsharma/zinc/pkg/handlers.ValidateCredentials(3handlers)[GIN-debug]PUT/api/user-->github.com/prabhatsharma/zinc/pkg/handlers.CreateUpdateUser(4handlers)[GIN-debug]DELETE/api/user/:userID-->github.com/prabhatsharma/zinc/pkg/handlers.DeleteUser(4handlers)[GIN-debug]GET/api/users-->github.com/prabhatsharma/zinc/pkg/handlers。GetUsers(4handlers)[GIN-debug]PUT/api/index-->github.com/prabhatsharma/zinc/pkg/handlers.CreateIndex(4handlers)[GIN-debug]GET/api/index-->github.com/帕巴沙尔ma/zinc/pkg/handlers.ListIndexes(4handlers)[GIN-debug]PUT/api/:target/document-->github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument(4handlers)[GIN-debug]POST/api/:target/_search-->github.com/prabhatsharma/zinc/pkg/handlers.SearchIndex(4handlers)[GIN-debug]PUT/es/:target/_doc/:id-->github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument(4handlers)[GIN-debug]DELETE/es/:target/_doc/:id-->github.com/prabhatsharma/zinc/pkg/handlers.DeleteDocument(4handlers)[GIN-调试]POST/es/:target/_doc-->github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument(4handlers)[GIN-debug]PUT/es/:target/_create/:id-->github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument(4handlers)[GIN-debug]POST/es/:target/_create/:id-->github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument(4handlers)[GIN-debug]POST/es/:target/_update/:id-->github.com/prabhatsharma/zinc/pkg/handlers.UpdateDocument(4handlers)[GIN-debug]POST/es/_bulk-->github.com/公关abhatsharma/zinc/pkg/handlers.BulkHandler(4handlers)[GIN-debug]POST/es/:target/_bulk-->github.com/prabhatsharma/zinc/pkg/handlers.BulkHandler(4handlers)[GIN-debug]ListeningandservingHTTPon:4080访问https://localhost:4080可以看到上面的界面。目前Go语言中文网站搜索使用的是Solr。如果有时间,请尝试验证Zinc。如果它稳定且成熟,请考虑迁移到Zinc。
