Skip to content

Commit

Permalink
remove heavy query
Browse files Browse the repository at this point in the history
/.*a.*/ takes 1.23 sec. Apply regex if word is longer
  • Loading branch information
swkim101 committed Aug 10, 2024
1 parent 708a88f commit d1df5c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api.cspapers.org/db/bleve/bleve.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func search(req *types.SearchRequest) *types.SearchResponse {
keywordQuery := []query.Query{}
req.Query = strings.TrimSpace(req.Query)
keywordQuery = append(keywordQuery, bleve.NewFuzzyQuery(req.Query))
if isWord(req.Query) {
if isWord(req.Query) && 3 < len(req.Query) {
qs := fmt.Sprintf("/.*%v.*/", req.Query)
keywordQuery = append(keywordQuery, bleve.NewQueryStringQuery(qs))
} else {
Expand Down Expand Up @@ -162,7 +162,7 @@ func search(req *types.SearchRequest) *types.SearchResponse {

func batchInsert() {
batch := index.NewBatch()
batchSize := 10000
batchSize := 1000

for i := 0; true; i++ {
req, more := <-reqChan
Expand Down

0 comments on commit d1df5c9

Please sign in to comment.