Contextual searches

The Sample bulk updates section briefly summarizes some of the PAPI behaviors you may want to search for in your configuration. This section provides a fuller set of examples showing different techniques to help refine your search.

Examples in the table below demonstrate how to restrict matches to top-level default rules, child rules, or match based on nearby criteria or behaviors. It shows how to match or exclude string values, pattern-match a regular expression, or test boolean, numeric, or array values.

The additional section on Possible mismatches provides further guidance on potential conceptual errors to help you avoid matching content incorrectly.

MatchJSONPath syntax
Location within rules
Origin hostname in top-level default rule.$.behaviors[?( == 'origin')].options.hostname
Origin hostname in any rule.$..behaviors[?( == 'origin')].options.hostname
Origin hostname, only in child rules.$..children[*].behaviors[?( == 'origin')].options.hostname
Boolean values
Toggle HTTP/2, when either enabled or disabled.$..behaviors[?( == 'http2')].options.enabled
Edge Redirector, disabled.$..behaviors[?( == 'edgeRedirector')].options[?(@.enabled == false)].enabled
Edge Redirector, enabled.$..behaviors[?( == 'edgeRedirector')].options[?(@.enabled == true)].enabled
Forward Rewrite or Edge Redirector, enabled or disabled.`$..behaviors[?( == 'forwardRewrite'
String values
Origin hostname of$..behaviors[?( == 'origin')].options[?(@.hostname == '')].hostname
Any origin hostname that matches an substring.$..behaviors[?( == 'origin')].options[?(@.hostname =~ /].hostname
Any origin hostname that starts with www. and ends .com.$..behaviors[?( == 'origin')].options[?(@.hostname =~ /www\..*\.com/)].hostname
Default caching TTL.$..behaviors[?( == 'caching')].options.defaultTtl
Same, but cached 1 to 9 hours.$..behaviors[?( == 'caching' && @.options.defaultTtl =~ /^[1-9]h$/)].options.defaultTtl
Numeric values
Any response code.$..behaviors[?( == 'responseCode')].options.statusCode
Response code is 200.$..behaviors[?( == 'responseCode')].options[?(@.statusCode == 200)].statusCode
Error response codes.$..behaviors[?( == 'responseCode')].options[?(@.statusCode >= 400)].statusCode
Redirect responses in 3xx range.$..behaviors[?( == 'responseCode')].options[?(@.statusCode >= 300 && @.statusCode < 400)].statusCode
Array values
Path criteria match that includes /catalog.$..criteria[?( == 'path')].options.value[?(@ == '/catalog')]
All path match values except /catalog.$..criteria[?( == 'path')].options.value[?(@ != '/catalog')]
All path match values.$..criteria[?( == 'path')].options.value[*]
First path match value.$..criteria[?( == 'path')].options.value[0]
Last path match value.$..criteria[?( == 'path')].options.value[-1]
Any /catalog path value in the same set as an /about value.$..criteria[?( == 'path')].options[?('/about' in @.value)].value[?(@ == '/catalog')]
Any /catalog path value where /blog isn't in the same set.$..criteria[?( == 'path')].options[?('/blog' nin @.value)].value[?(@ == '/catalog')]
Specific set of path values.`$..criteria[?( == 'path')].options.value[?(@ == '/catalog'
Relative location
Toggle Image Manager within any rule with image in its name.$..children[?( =~ /[Ii]mage/)].behaviors[?( == 'imageManager')].options.enabled
Toggle a matchWildcard option within a contentType match that enables a gzipResponse behavior.$.[?(@.criteria.[?( == 'contentType')] && @.behaviors.[?( == 'gzipResponse')])].criteria[?( == 'contentType')].options.matchWildcard
Set the Downstream Cacheability behavior when triggered by a Response Cacheability criteria match.$..children[?(@.criteria[?( == 'cacheability')] && @.behaviors[?( == 'downstreamCache')] )].behaviors[?( == 'downstreamCache')].options.behavior