Using Search Operators with GFSearch

//

BrightLeaf

The operators attribute in GFSearch allows you to define how each search value is compared to its corresponding field in the search attribute. It should be a comma-separated list, with each operator matching its position to the same-positioned field ID in the search attribute.

Supported Operators

OperatorMeaning
= or isEquals
!=isnotis notNot equal to
containsPartial match
likeSQL-style LIKE with custom wildcards
inValue is in array
notinnot inValue is NOT in array
gtGreater than
ltLess than
gt=Greater than or equal to
lt=Less than or equal to

To compare against multiple values using in or not in, pass a PHP-style array in the shortcode content, like:

array('item one', 'item two', 'item three')

Operator Matching Behavior

Each operator in operators must match the position of a field in the search attribute:

  •  If you pass fewer operators than search fields:
    • The remaining fields default to = (exact match).
    • This lets you apply advanced filters only where needed.
  •  If you pass more operators than search fields:
    • Extra operators are ignored.
  •  If operators is omitted entirely:
    • All search fields use = by default.

Examples

Basic match with mixed operators

[gfsearch search="3,5,8" operators="contains,=,gt"]
Smith|john@example.com|50
[/gfsearch]
  • Field 3 must contain “Smith”
  • Field 5 must equal “john@example.com
  • Field 8 must be greater than 50

Using array for in

[gfsearch search="5" operators="in"]
array('yes','maybe')
[/gfsearch]
  • Field 5 must match one of the given values

Mixing defaults and explicit operators

[gfsearch search="3,5,8" operators="contains"]
Smith|john@example.com|50
[/gfsearch]
  • Field 3 uses contains
  • Field 5 and 8 default to =

Tips & Gotchas

  • Array format: Use array('one','two') exactly—do not just write comma-separated values.
  • Order matters: Ensure your operators match the order of search fields.
  • If a field is repeated in search, you can still assign distinct operators per instance.
  • The greater_than and less_than attributes are deprecated in favor of the new operators attribute.