Skip to content

Commit

Permalink
Move MustCompile out (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-xie committed Nov 16, 2022
1 parent 4699ae3 commit 7778e81
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/persistence/elasticsearch/esVisibilityStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ var (
}
)

var missingStartTimeRegex = regexp.MustCompile(jsonMissingStartTime)

func getESQueryDSLForScan(request *p.ListWorkflowExecutionsByQueryRequest) (string, error) {
sql := getSQLFromListRequest(request)
dsl, err := getCustomizedDSLFromSQL(sql, request.DomainUUID)
Expand Down Expand Up @@ -631,8 +633,7 @@ func replaceQueryForOpen(dsl *fastjson.Value) *fastjson.Value {
// ES v6 only accepts "must_not exists" query instead of "missing" query, but elasticsql produces "missing",
// so use this func to replace.
func replaceQueryForUninitialized(dsl *fastjson.Value) *fastjson.Value {
re := regexp.MustCompile(jsonMissingStartTime)
newDslStr := re.ReplaceAllString(dsl.String(), `{"bool":{"must_not":{"exists":{"field":"StartTime"}}}}`)
newDslStr := missingStartTimeRegex.ReplaceAllString(dsl.String(), `{"bool":{"must_not":{"exists":{"field":"StartTime"}}}}`)
dsl = fastjson.MustParse(newDslStr)
return dsl
}
Expand Down

0 comments on commit 7778e81

Please sign in to comment.