From 7c4209a87a1ed926566d707cfcb6f74e2cd3406b Mon Sep 17 00:00:00 2001 From: "suguo.yao" Date: Sat, 15 Oct 2022 11:06:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=B5=8B=E8=AF=95=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-test.http | 37 ++++++++++++++++++++++++++++++++----- web/controller/index.go | 6 ++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/api-test.http b/api-test.http index e601afe..3d184f6 100644 --- a/api-test.http +++ b/api-test.http @@ -1,9 +1,9 @@ -# @url=http://admin:123456@192.168.0.254:5678/api +@url=http://admin:123456@192.168.0.254:5678/api # @url=http://192.168.0.254:5678/api -@url=http://127.0.0.1:5678/api +# @url=http://127.0.0.1:5678/api ###增加/修改索引 -POST {{url}}/index?database=default HTTP/1.1 +POST {{url}}/index?database=aaa HTTP/1.1 Authorization: { @@ -15,6 +15,18 @@ Authorization: } } +###增加/修改索引 没有database时database is empty" +POST {{url}}/index?database=default HTTP/1.1 +Authorization: + +{ + "text": "北京北三站", + "document": { + "title": "阿森松岛所245", + "number": 226 + } +} + ###批量增加/修改索引 POST {{url}}/index/batch?database=default HTTP/1.1 @@ -55,7 +67,22 @@ POST {{url}}/query HTTP/1.1 } } -#### 查询索引 +#### 查询索引2 POST {{url}}/query?database=default HTTP/1.1 -{"query":"北京","page":1,"limit":10,"highlight":{"preTag":"","postTag":""},"order":"DESC"} \ No newline at end of file +{"query":"北京","page":1,"limit":10,"highlight":{"preTag":"","postTag":""},"order":"DESC"} + +#### 查询状态 +GET {{url}}/status HTTP/1.1 + +#### 创建数据库 +GET {{url}}/db/create?database=aaa HTTP/1.1 + +#### 删除数据库 数据库不存在 +GET {{url}}/db/drop?database=aaa HTTP/1.1 + +#### 显示数据库 +GET {{url}}/db/list HTTP/1.1 + +#### 在线分词 +GET {{url}}/word/cut?q=上海和深圳哪个城市幸福指数高 HTTP/1.1 \ No newline at end of file diff --git a/web/controller/index.go b/web/controller/index.go index 4f73920..ad0ed9c 100644 --- a/web/controller/index.go +++ b/web/controller/index.go @@ -14,8 +14,7 @@ func AddIndex(c *gin.Context) { } dbName := c.Query("database") if dbName == "" { - ResponseErrorWithMsg(c, "database is empty") - return + dbName = "default" } err := srv.Index.AddIndex(dbName, document) if err != nil { @@ -36,8 +35,7 @@ func BatchAddIndex(c *gin.Context) { dbName := c.Query("database") if dbName == "" { - ResponseErrorWithMsg(c, "database is empty") - return + dbName = "default" } err := srv.Index.BatchAddIndex(dbName, documents)