@@ -173,31 +173,33 @@ func (q *queryBuilder) buildEntityScopeQuery() (*v1.Query, error) {
173173 fieldLabel == search .DeploymentAnnotation ||
174174 fieldLabel == search .NamespaceAnnotation
175175
176- values := make ([]string , 0 , len (rule .GetValues ()))
177- for _ , rv := range rule .GetValues () {
178- val := rv .GetValue ()
179- if rv .GetMatchType () == storage .MatchType_REGEX {
180- val = search .RegexPrefix + val
181- }
182- values = append (values , val )
183- }
184-
185- if len (values ) == 0 {
176+ if len (rule .GetValues ()) == 0 {
186177 continue
187178 }
188179
189180 if isMapField {
190- for _ , v := range values {
191- key , value := splitLabelValue (v )
192- conjuncts = append (conjuncts ,
181+ mapQueries := make ([]* v1.Query , 0 , len (rule .GetValues ()))
182+ for _ , rv := range rule .GetValues () {
183+ val := rv .GetValue ()
184+ key , value := splitLabelValue (val )
185+ mapQueries = append (mapQueries ,
193186 search .NewQueryBuilder ().AddMapQuery (fieldLabel , key , value ).ProtoQuery ())
194187 }
195- } else if rule .GetValues ()[0 ].GetMatchType () == storage .MatchType_REGEX {
196- conjuncts = append (conjuncts ,
197- search .NewQueryBuilder ().AddStrings (fieldLabel , values ... ).ProtoQuery ())
188+ conjuncts = append (conjuncts , search .DisjunctionQuery (mapQueries ... ))
198189 } else {
199- conjuncts = append (conjuncts ,
200- search .NewQueryBuilder ().AddExactMatches (fieldLabel , values ... ).ProtoQuery ())
190+ var ruleQueries []* v1.Query
191+ for _ , rv := range rule .GetValues () {
192+ val := rv .GetValue ()
193+ if rv .GetMatchType () == storage .MatchType_REGEX {
194+ val = search .RegexPrefix + val
195+ ruleQueries = append (ruleQueries ,
196+ search .NewQueryBuilder ().AddStrings (fieldLabel , val ).ProtoQuery ())
197+ } else {
198+ ruleQueries = append (ruleQueries ,
199+ search .NewQueryBuilder ().AddExactMatches (fieldLabel , val ).ProtoQuery ())
200+ }
201+ }
202+ conjuncts = append (conjuncts , search .DisjunctionQuery (ruleQueries ... ))
201203 }
202204 }
203205
0 commit comments