@@ -221,7 +221,7 @@ export const QueryBuilderProvider: FC = ({children}) => {
221221 ? tagSelections . join ( ' and ' )
222222 : 'true'
223223 const searchString = search
224- ? `\n |> filter(fn: (r) => r._value =~ /( ?i:${ search } )/ )`
224+ ? `\n |> filter(fn: (r) => r._value =~ regexp.compile(v: "( ?i:" + regexp.quoteMeta(v: " ${ search } ") + ")") )`
225225 : ''
226226 const previousTagSelections = cards
227227 . slice ( 0 , idx )
@@ -232,11 +232,11 @@ export const QueryBuilderProvider: FC = ({children}) => {
232232
233233 const { scope} = getPanelQueries ( id )
234234
235- let _source
235+ let _source = 'import "regexp"\n'
236236 if ( data . buckets [ 0 ] . type === 'sample' ) {
237- _source = `import "influxdata/influxdb/sample"\nsample.data(set: "${ data . buckets [ 0 ] . id } ")`
237+ _source + = `import "influxdata/influxdb/sample"\nsample.data(set: "${ data . buckets [ 0 ] . id } ")`
238238 } else {
239- _source = `from(bucket: "${ data . buckets [ 0 ] . name } ")`
239+ _source + = `from(bucket: "${ data . buckets [ 0 ] . name } ")`
240240 }
241241
242242 const limit = isFlagEnabled ( 'increasedMeasurmentTagLimit' )
@@ -326,15 +326,15 @@ export const QueryBuilderProvider: FC = ({children}) => {
326326 ? tagSelections . join ( ' and ' )
327327 : 'true'
328328 const searchString = search
329- ? `\n |> filter(fn: (r) => r._value =~ /( ?i:${ search } )/ )`
329+ ? `\n |> filter(fn: (r) => r._value =~ regexp.compile(v: "( ?i:" + regexp.quoteMeta(v: " ${ search } ") + ")") )`
330330 : ''
331331
332332 const { scope} = getPanelQueries ( id )
333- let _source
333+ let _source = 'import "regexp"\n'
334334 if ( data . buckets [ 0 ] . type === 'sample' ) {
335- _source = `import "influxdata/influxdb/sample"\nsample.data(set: "${ data . buckets [ 0 ] . id } ")`
335+ _source + = `import "influxdata/influxdb/sample"\nsample.data(set: "${ data . buckets [ 0 ] . id } ")`
336336 } else {
337- _source = `from(bucket: "${ data . buckets [ 0 ] . name } ")`
337+ _source + = `from(bucket: "${ data . buckets [ 0 ] . name } ")`
338338 }
339339
340340 // TODO: Use the `v1.tagValues` function from the Flux standard library once
0 commit comments