mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-12 20:03:40 +08:00
Implement Elasticsearch functions in GO (#15160)
### What problem does this PR solve? Implement Elasticsearch functions in GO (except for Search) ### Type of change - [x] Refactoring
This commit is contained in:
@@ -133,7 +133,7 @@ func (h *ChunkHandler) Get(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
chunkID := c.Query("chunk_id")
|
||||
chunkID := c.Param("chunk_id")
|
||||
if chunkID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 400,
|
||||
@@ -337,7 +337,7 @@ func (h *ChunkHandler) UpdateChunk(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// Remove handles chunk removal requests
|
||||
// RemoveChunks handles chunk removal requests
|
||||
// @Summary Remove Chunks
|
||||
// @Description Remove chunks from a document
|
||||
// @Tags chunks
|
||||
@@ -345,14 +345,24 @@ func (h *ChunkHandler) UpdateChunk(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Param request body service.RemoveChunksRequest true "remove chunks request"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Router /v1/chunk/rm [post]
|
||||
func (h *ChunkHandler) Remove(c *gin.Context) {
|
||||
// @Router /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks [delete]
|
||||
func (h *ChunkHandler) RemoveChunks(c *gin.Context) {
|
||||
user, errorCode, errorMessage := GetUser(c)
|
||||
if errorCode != common.CodeSuccess {
|
||||
jsonError(c, errorCode, errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
// Get document_id from URL path
|
||||
docID := c.Param("document_id")
|
||||
if docID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 400,
|
||||
"message": "document_id is required",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var req service.RemoveChunksRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
@@ -362,6 +372,8 @@ func (h *ChunkHandler) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
req.DocID = docID
|
||||
|
||||
if req.DocID == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 400,
|
||||
|
||||
Reference in New Issue
Block a user