Skip to content

Commit 3c06bad

Browse files
committed
Add support for tags_all parameter with AND logic
Implemented a new tags_all query parameter that works alongside the existing tags parameter to support both OR and AND tag filtering logic: - tags: Filters with OR logic (matches resources with ANY of the tags) - tags_all: Filters with AND logic (matches resources with ALL of the tags) - Both parameters can be used together in a single query Changes: - Updated API design to include tags_all parameter - Modified OpenSearch template to handle tags_all in must clause - Updated mock implementation with two-pass filtering - Added TagsAll field to SearchCriteria domain model - Updated all converter functions to map tags_all from payload - Added comprehensive test coverage for both parameters - Regenerated Goa API code 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andres Tobon <[email protected]>
1 parent f5c5c55 commit 3c06bad

File tree

17 files changed

+342
-39
lines changed

17 files changed

+342
-39
lines changed

cmd/service/converters.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func (s *querySvcsrvc) payloadToCriteria(ctx context.Context, p *querysvc.QueryR
2222
Parent: p.Parent,
2323
ResourceType: p.Type,
2424
Tags: p.Tags,
25+
TagsAll: p.TagsAll,
2526
SortBy: p.Sort,
2627
PageToken: p.PageToken,
2728
PageSize: constants.DefaultPageSize,
@@ -91,6 +92,7 @@ func (s *querySvcsrvc) payloadToCountPublicCriteria(payload *querysvc.QueryResou
9192

9293
// Set the criteria from the payload
9394
criteria.Tags = payload.Tags
95+
criteria.TagsAll = payload.TagsAll
9496
if payload.Name != nil {
9597
criteria.Name = payload.Name
9698
}
@@ -119,6 +121,7 @@ func (s *querySvcsrvc) payloadToCountAggregationCriteria(payload *querysvc.Query
119121

120122
// Set the criteria from the payload
121123
criteria.Tags = payload.Tags
124+
criteria.TagsAll = payload.TagsAll
122125
if payload.Name != nil {
123126
criteria.Name = payload.Name
124127
}

design/query-svc.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ var _ = dsl.Service("query-svc", func() {
5050
dsl.Attribute("type", dsl.String, "Resource type to search", func() {
5151
dsl.Example("committee")
5252
})
53-
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search (varies by object type)", func() {
54-
dsl.Example([]string{"active"})
53+
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search with OR logic - matches resources with any of these tags", func() {
54+
dsl.Example([]string{"active", "public"})
55+
})
56+
dsl.Attribute("tags_all", dsl.ArrayOf(dsl.String), "Tags to search with AND logic - matches resources that have all of these tags", func() {
57+
dsl.Example([]string{"governance", "security"})
5558
})
5659
dsl.Required("bearer_token", "version")
5760
})
@@ -74,6 +77,7 @@ var _ = dsl.Service("query-svc", func() {
7477
dsl.Param("parent")
7578
dsl.Param("type")
7679
dsl.Param("tags")
80+
dsl.Param("tags_all")
7781
dsl.Param("sort")
7882
dsl.Param("page_token")
7983
dsl.Header("bearer_token:Authorization")
@@ -110,8 +114,11 @@ var _ = dsl.Service("query-svc", func() {
110114
dsl.Attribute("type", dsl.String, "Resource type to search", func() {
111115
dsl.Example("committee")
112116
})
113-
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search (varies by object type)", func() {
114-
dsl.Example([]string{"active"})
117+
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search with OR logic - matches resources with any of these tags", func() {
118+
dsl.Example([]string{"active", "public"})
119+
})
120+
dsl.Attribute("tags_all", dsl.ArrayOf(dsl.String), "Tags to search with AND logic - matches resources that have all of these tags", func() {
121+
dsl.Example([]string{"governance", "security"})
115122
})
116123
dsl.Required("bearer_token", "version")
117124
})
@@ -138,6 +145,7 @@ var _ = dsl.Service("query-svc", func() {
138145
dsl.Param("parent")
139146
dsl.Param("type")
140147
dsl.Param("tags")
148+
dsl.Param("tags_all")
141149
dsl.Header("bearer_token:Authorization")
142150
dsl.Response(dsl.StatusOK, func() {
143151
dsl.Header("cache_control:Cache-Control")

gen/http/cli/lfx_v2_query_service/cli.go

Lines changed: 23 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)