fix: search, question add title search

This commit is contained in:
kumfo 2022-10-14 12:28:11 +08:00
parent 158abbef42
commit 53910b80ab
4 changed files with 7 additions and 5 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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)

View File

@ -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})
}