Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit b18be27
Author: Mantas Šidlauskas <mantass@netapp.com>
Date:   Tue Apr 18 14:12:09 2023 +0300

    Add generic ES query building utilities (#5168)

commit 824f0ac
Author: agautam478 <72432016+agautam478@users.noreply.github.com>
Date:   Fri Apr 14 13:37:29 2023 -0700

    Fixed the nil pointer issues in the InactiveDomain Invariant (#5213)

commit c5678dd
Author: Ketsia <115650494+ketsiambaku@users.noreply.github.com>
Date:   Wed Apr 12 15:21:10 2023 -0700

    Fix consistent query metric (#5170)

    * add shardid tag to log

    * remove counter for overall scope

    * fix lint

commit eade936
Author: David Porter <david.porter@uber.com>
Date:   Wed Apr 12 13:54:13 2023 -0700

    Corrects the config-store handling for not-found errors (#5203)

commit 9fc4485
Author: lancezhao-ins <99238165+lancezhao-ins@users.noreply.github.com>
Date:   Tue Apr 11 04:21:15 2023 +1000

    Allow registering search attributes without Advance Visibility enabled (#5185)

    * remove validation & test for add search attribute with no advanced config

    - Remove validation for Advance Visibility Store
    - Add Advance Visibility Config check before update ElasticSearch/OpenSearch mapping
    - Remove co-related test for 'no advanced config'

    * Update CHANGELOG.md

    Update CHANGELOG.md

    * Add warn level message if skip updating OpenSearch/ElasticSearch mapping

    * Add warn level message and add validSearchAttributes in development.yaml

    ---------

    Co-authored-by: Quanzheng Long <prclqz@gmail.com>

commit d165c7b
Author: neil-xie <104041627+neil-xie@users.noreply.github.com>
Date:   Mon Apr 10 10:46:04 2023 -0700

    Update idls version (#5200)

commit b2bc8bf
Author: Mantas Šidlauskas <mantass@netapp.com>
Date:   Mon Apr 10 20:12:53 2023 +0300

    Add thin ES clients (#5162)

    * Add thin ES clients
  • Loading branch information
davidporter-id-au committed Apr 19, 2023
1 parent bc63f17 commit c405734
Show file tree
Hide file tree
Showing 19 changed files with 1,333 additions and 36 deletions.
274 changes: 272 additions & 2 deletions .gen/go/indexer/indexer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions common/elasticsearch/client_v6.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/uber/cadence/common"
"github.com/uber/cadence/common/config"
"github.com/uber/cadence/common/elasticsearch/query"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/log/tag"
p "github.com/uber/cadence/common/persistence"
Expand All @@ -53,7 +54,7 @@ type (
// searchParametersV6 holds all required and optional parameters for executing a search
searchParametersV6 struct {
Index string
Query elastic.Query
Query query.Query
From int
PageSize int
Sorter []elastic.Sorter
Expand Down Expand Up @@ -126,9 +127,9 @@ func (c *elasticV6) Search(ctx context.Context, request *SearchRequest) (*p.Inte
return nil, err
}

var matchQuery *elastic.MatchQuery
var matchQuery *query.MatchQuery
if request.MatchQuery != nil {
matchQuery = elastic.NewMatchQuery(request.MatchQuery.Name, request.MatchQuery.Text)
matchQuery = query.NewMatchQuery(request.MatchQuery.Name, request.MatchQuery.Text)
}

searchResult, err := c.getSearchResult(
Expand Down Expand Up @@ -214,10 +215,10 @@ func (c *elasticV6) SearchForOneClosedExecution(
request *p.InternalGetClosedWorkflowExecutionRequest,
) (*p.InternalGetClosedWorkflowExecutionResponse, error) {

matchDomainQuery := elastic.NewMatchQuery(DomainID, request.DomainUUID)
existClosedStatusQuery := elastic.NewExistsQuery(CloseStatus)
matchWorkflowIDQuery := elastic.NewMatchQuery(WorkflowID, request.Execution.GetWorkflowID())
boolQuery := elastic.NewBoolQuery().Must(matchDomainQuery).Must(existClosedStatusQuery).Must(matchWorkflowIDQuery)
matchDomainQuery := query.NewMatchQuery(DomainID, request.DomainUUID)
existClosedStatusQuery := query.NewExistsQuery(CloseStatus)
matchWorkflowIDQuery := query.NewMatchQuery(WorkflowID, request.Execution.GetWorkflowID())
boolQuery := query.NewBoolQuery().Must(matchDomainQuery).Must(existClosedStatusQuery).Must(matchWorkflowIDQuery)
rid := request.Execution.GetRunID()
if rid != "" {
matchRunIDQuery := elastic.NewMatchQuery(RunID, rid)
Expand Down Expand Up @@ -412,13 +413,13 @@ func (c *elasticV6) getSearchResult(
ctx context.Context,
index string,
request *p.InternalListWorkflowExecutionsRequest,
matchQuery *elastic.MatchQuery,
matchQuery *query.MatchQuery,
isOpen bool,
token *ElasticVisibilityPageToken,
) (*elastic.SearchResult, error) {

// always match domain id
boolQuery := elastic.NewBoolQuery().Must(elastic.NewMatchQuery(DomainID, request.DomainUUID))
boolQuery := query.NewBoolQuery().Must(query.NewMatchQuery(DomainID, request.DomainUUID))

if matchQuery != nil {
boolQuery = boolQuery.Must(matchQuery)
Expand All @@ -434,7 +435,7 @@ func (c *elasticV6) getSearchResult(
}

var rangeQueryField string
existClosedStatusQuery := elastic.NewExistsQuery(CloseStatus)
existClosedStatusQuery := query.NewExistsQuery(CloseStatus)
if isOpen {
rangeQueryField = StartTime
boolQuery = boolQuery.MustNot(existClosedStatusQuery)
Expand All @@ -445,7 +446,7 @@ func (c *elasticV6) getSearchResult(

earliestTimeStr := strconv.FormatInt(request.EarliestTime.UnixNano()-oneMicroSecondInNano, 10)
latestTimeStr := strconv.FormatInt(request.LatestTime.UnixNano()+oneMicroSecondInNano, 10)
rangeQuery := elastic.NewRangeQuery(rangeQueryField).Gte(earliestTimeStr).Lte(latestTimeStr)
rangeQuery := query.NewRangeQuery(rangeQueryField).Gte(earliestTimeStr).Lte(latestTimeStr)
boolQuery = boolQuery.Filter(rangeQuery)

params := &searchParametersV6{
Expand All @@ -455,8 +456,8 @@ func (c *elasticV6) getSearchResult(
PageSize: request.PageSize,
}

params.Sorter = append(params.Sorter, elastic.NewFieldSort(rangeQueryField).Desc())
params.Sorter = append(params.Sorter, elastic.NewFieldSort(RunID).Desc())
params.Sorter = append(params.Sorter, query.NewFieldSort(rangeQueryField).Desc())
params.Sorter = append(params.Sorter, query.NewFieldSort(RunID).Desc())

if ShouldSearchAfter(token) {
params.SearchAfter = []interface{}{token.SortValue, token.TieBreaker}
Expand Down
Loading

0 comments on commit c405734

Please # to comment.