Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: search, question add title search

kumfo53910b80ab68
diff --git a/docs/docs.go b/docs/docs.go
index d0ecc7d0..f4ac833c 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2150,7 +2150,7 @@ const docTemplate = `{
}
},
"/answer/api/v1/question/page": {
- "post": {
+ "get": {
"description": "SearchQuestionList \u003cbr\u003e \"order\" Enums(newest, active,frequent,score,unanswered)",
"consumes": [
"application/json"
diff --git a/docs/swagger.json b/docs/swagger.json
index fda881be..11c99f4d 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2138,7 +2138,7 @@
}
},
"/answer/api/v1/question/page": {
- "post": {
+ "get": {
"description": "SearchQuestionList \u003cbr\u003e \"order\" Enums(newest, active,frequent,score,unanswered)",
"consumes": [
"application/json"
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index b13a2092..a88b3ca6 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -2656,7 +2656,7 @@ paths:
tags:
- api-question
/answer/api/v1/question/page:
- post:
+ get:
consumes:
- application/json
description: SearchQuestionList <br> "order" Enums(newest, active,frequent,score,unanswered)
diff --git a/internal/repo/search_repo.go b/internal/repo/search_repo.go
index f6277c19..f208c2e2 100644
--- a/internal/repo/search_repo.go
+++ b/internal/repo/search_repo.go
@@ -70,7 +70,8 @@ func (sr *searchRepo) SearchContents(ctx context.Context, words []string, tagID,
for i, word := range words {
if i == 0 {
- b.Where(builder.Like{"original_text", word})
+ b.Where(builder.Like{"title", word}).
+ Or(builder.Like{"original_text", word})
ub.Where(builder.Like{"`answer`.original_text", word})
} else {
b.Or(builder.Like{"original_text", word})
@@ -137,7 +138,8 @@ func (sr *searchRepo) SearchQuestions(ctx context.Context, words []string, limit
for i, word := range words {
if i == 0 {
- b.Where(builder.Like{"original_text", word})
+ b.Where(builder.Like{"title", word}).
+ Or(builder.Like{"original_text", word})
} else {
b.Or(builder.Like{"original_text", word})
}