Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >gofound 试用

gofound 试用

作者头像
golangLeetcode
发布于 2023-09-06 11:24:19
发布于 2023-09-06 11:24:19
54300
代码可运行
举报
运行总次数:0
代码可运行

https://github.com/sea-team/gofound是纯go实现的一个类es的简易版本搜索引擎。支持全文检索引擎 基于平衡二叉树+正排索引、倒排索引实现 可支持亿级数据,毫秒级查询。使用简单,使用http接口。

安装

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
go get && go build

启动

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% ./gofound --addr=:8080 --data=./data
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /admin/                   --> github.com/sea-team/gofound/web/admin.adminIndex (4 handlers)
[GIN-debug] GET    /assets/*filepath         --> github.com/sea-team/gofound/web/admin.handlerStatic (4 handlers)
2023/04/15 21:53:47 Admin Url:   http://:8080/admin
[GIN-debug] GET    /api/                     --> github.com/sea-team/gofound/web/controller.Welcome (6 handlers)
[GIN-debug] POST   /api/query                --> github.com/sea-team/gofound/web/controller.Query (6 handlers)
[GIN-debug] GET    /api/status               --> github.com/sea-team/gofound/web/controller.Status (6 handlers)
[GIN-debug] GET    /api/gc                   --> github.com/sea-team/gofound/web/controller.GC (6 handlers)
[GIN-debug] POST   /api/index                --> github.com/sea-team/gofound/web/controller.AddIndex (6 handlers)
[GIN-debug] POST   /api/index/batch          --> github.com/sea-team/gofound/web/controller.BatchAddIndex (6 handlers)
[GIN-debug] POST   /api/index/remove         --> github.com/sea-team/gofound/web/controller.RemoveIndex (6 handlers)
[GIN-debug] GET    /api/db/list              --> github.com/sea-team/gofound/web/controller.DBS (6 handlers)
[GIN-debug] GET    /api/db/drop              --> github.com/sea-team/gofound/web/controller.DatabaseDrop (6 handlers)
[GIN-debug] GET    /api/db/create            --> github.com/sea-team/gofound/web/controller.DatabaseCreate (6 handlers)
[GIN-debug] GET    /api/word/cut             --> github.com/sea-team/gofound/web/controller.WordCut (6 handlers)
2023/04/15 21:53:47 API Url:     http://:8080/api

查看admin后台

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
http://127.0.0.1:8080/admin/#/

查看api接口

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
http://127.0.0.1:8080/api/
{
state: true,
message: "success",
data: "Welcome to GoFound"
}

gofound启动之后,会监听一个TCP端口,接收来自客户端的搜索请求。处理http请求部分使用gin框架。如果不指定,默认数据库为default。

插入数据

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 % curl -H "Content-Type:application/json" -X POST --data '{"id":88888,"text":"深圳北站","document":{"title":"阿森松岛所445","number":223}}' 'http://127.0.0.1:8080/api/index?database=default'
{"state":true,"message":"success"}

批量插入

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
curl -H "Content-Type:application/json" -X POST --data '[
  {
    "id": 88888,
    "text": "深圳北站",
    "document": {
      "title": "阿森松岛所445",
      "number": 223
    }
  },
  {
    "id": 22222,
    "text": "北京东站",
    "document": {
      "title": "123123123",
      "number": 123123
    }
  }
]' 'http://127.0.0.1:8080/api/index/batch?database=default'

{"state":true,"message":"success"}

查询状态

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% curl http://127.0.0.1:8080/api/status
{"state":true,"message":"success","data":{"cpu":{"cores":4,"usedPercent":9.43,"modelName":"Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz"},"disk":{"total":233.57,"used":216.64,"free":16.93,"fsType":"apfs","usedPercent":92.75,"path":"/"},"memory":{"total":8,"used":5.62,"free":0.14,"self":0.05,"usedPercent":70.28},"system":{"arch":"amd64","bufferNum":1000,"cores":4,"dataPath":"./data","dataSize":8.25,"dbs":1,"debug":true,"dictionaryPath":"./data/dictionary.txt","enableAuth":false,"enableGzip":true,"executable":"./gofound","gomaxprocs":8,"goroutines":53,"os":"darwin","pid":54603,"shard":0,"version":"go1.19"}}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% curl http://127.0.0.1:8080/api/db/list
{"state":true,"message":"success","data":{"default":{"IndexPath":"./data/default","Option":{"InvertedIndexName":"inverted_index","PositiveIndexName":"positive_index","DocIndexName":"docs"},"IsDebug":true,"Tokenizer":{},"DatabaseName":"default","Shard":10,"Timeout":600,"BufferNum":1000}}}

查询

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 %  curl -H "Content-Type:application/json" -X POST --data '{"query":"深圳北站","page":1,"limit":10,"order":"desc"}' http://127.0.0.1:8080/api/query
{"state":true,"message":"success","data":{"time":107.278619,"total":1,"pageCount":1,"page":1,"limit":10,"documents":[{"id":88888,"text":"深圳北站","document":{"number":223,"title":"阿森松岛所445"},"score":2,"keys":["深圳","北站"]}],"words":["深圳","北站"]}}

分词

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
% curl 'http://127.0.0.1:8080/api/word/cut?q=上海和深圳哪个城市幸福指数高'
{"state":true,"message":"success","data":["上海","和","深圳","哪个","城市","幸福","指数","高"]}
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-04-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 golang算法架构leetcode技术php 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
Gin 7
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 的简单传参 同时使用 Query 和 PostForm gin 的 A
franket
2021/08/10
4870
Gin 12
使用 model binding 来将请求中的数据绑定到一个 model 中,形成一个结构体,Gin 可以对 Query String 进行绑定
franket
2021/08/10
3540
Gin 15
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 渲染 XML JSON 和 YAML gin 的 API 可以参考 A
franket
2021/08/10
2880
Gin 2
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 的基础用法 gin 的 API 可以参考 API REFFERENCE
franket
2021/08/10
3260
【Go API 开发实战 5】基础1:启动一个最简单的 RESTful API 服务器
要编写一个 RESTful 风格的 API 服务器,首先需要一个 RESTful Web 框架,笔者经过调研选择了 GitHub star 数最多的 Gin。采用轻量级的 Gin 框架,具有如下优点:高性能、扩展性强、稳定性强、相对而言比较简洁(查看 性能对比)。关于 Gin 的更多介绍可以参考 Golang 微框架 Gin 简介。
腾讯技术工程官方号
2019/05/16
2.4K0
【Go API 开发实战 5】基础1:启动一个最简单的 RESTful API 服务器
Gin 6
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 的简单传参 Param gin 的 API 可以参考 API REFF
franket
2021/08/10
3990
Gin 13
使用 model binding 来将请求中的数据绑定到一个 model 中,形成一个结构体,Gin 可以对 Query String 进行绑定
franket
2021/08/10
3430
Gin 9
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 如何上传多个文件 gin 的 API 可以参考 API REFFERE
franket
2021/08/10
4490
Gin 14
这里演示一下 Gin 的模型绑定 Multipart/Urlencoded binding
franket
2021/08/10
3760
Gin 5
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 的 PostForm 传参 gin 的 API 可以参考 API RE
franket
2021/08/10
4790
Gin 8
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 如何上传文件 gin 的 API 可以参考 API REFFERENC
franket
2021/08/10
5350
Gin-Web-Framework官方指南中文(下篇)
ShouldBind,ShouldBindJSON,ShouldBindXML,ShouldBindQuery,ShouldBindYAML
小诚信驿站
2019/10/31
2.4K0
Gin-Web-Framework官方指南中文(下篇)
OpenAPITools 实践
OpenAPITools[1] 可以依据 REST API 描述文件,自动生成服务端桩(Stub)代码、客户端 SDK 代码,及文档等。其是社区版的 Swagger[2] ,差异可见:OpenAPI Generator vs Swagger Codegen[3]。
GoCoding
2021/11/11
9740
OpenAPITools 实践
Gin 17
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 渲染 AsciiJSON gin 的 API 可以参考 API REF
franket
2021/08/10
4320
开发外包--golang熟练之gin & net(二)
Godev
2023/07/26
6410
深入Gin框架内幕(一) 顶
Gin是一个用 Go (Golang) 编写的 web 框架。它是一个类似于martini但性能更好的API框架,不同于谢大主导的Beegoweb框架,后者更像是Python语言中的Django框架,内部包含了开发一个web程序所需的各种组件。
BGBiao
2020/02/13
1.8K0
Gin 11
使用 model binding 来将请求中的数据绑定到一个 model 中,形成一个结构体,Gin 目前支持绑定 JSON XML 和标准的表单数据 (foo=bar&boo=baz)
franket
2021/08/10
4820
Gin 16
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 渲染 SecureJSON gin 的 API 可以参考 API RE
franket
2021/08/10
4340
Gin 3
前言 Gin 是一款用 Go(Golang) 编写的 web 框架 Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter 因为 httprouter, 它提供了更高的性能 这里演示一下 Gin 的简单传参 gin 的 API 可以参考 API REFFERENCE
franket
2021/08/10
3670
k8sailor - 05 设计 RESTful API 和 HTTP 响应数据
可以看到, k8s api 中都有一个对应的 kind 描述资源类型, 这个正好符合 RESTful 中资源定位的需求。
老麦
2022/12/24
4390
相关推荐
Gin 7
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验