Comparison Operators

Comparison operators are used to specify the field and value comparisons used for the search.

$EQ and $NE

  • Available Since API Version – 2.7

The $EQ and $NE operators are used for doing exact comparisons against the value in a field. When an $EQ operator is included in a search, only those entries with a value that exactly matches the supplied value for the specified field will be returned. Conversely, when the $NE operator is included in a search, any entries that do not exactly match the supplied value for the specified field will be returned.

Supported Field Types

The $EQ and $NE operators are supported for the following field types for most entity types.

Certain entity types may contain some fields that do not support all available search operators. If you try to search on a field using an unsupported operator, the response will contain an error message indicating that the operator is unsupported for that field.

  • BooleanField
  • CurrencyField
  • DateTimeField
  • Key
  • NumericField
  • SecAccessField
  • StringField
  • TxDictionaryField

Examples

The examples below illustrate how to use the $EQ and $NE operators when constructing a search query.

$EQ Example With StringField

The following is an example of an $EQ search on the CompanyName field that would be used to retrieve Address Book entries with the specified name.

{
  "CompanyName":{
    "$EQ":"ABC Wine Shop"
  }
}

$EQ Example With NumericField

The following is an example of an $EQ search for entries that have the value 11.254 in the numeric user-defined field with Type_Id 111. Only entries that have exactly the value 11.25 in this field will be returned by the search.

{
  "Udf/$TYPEID(111)":{
    "$EQ":11.25
  }
}

$NE Example With IntegerField

The following is an example of an $NE search for entries that do not have the value 100 value in the numeric user-defined field with Type_Id 111. Any entries that do not have exactly 100 in this field will be returned by the search.

{
  "Udf/$TYPEID(111)":{
    "$NE":100
  }
}

$NE Example With DateTimeField

The following is an example of an $NE search which would retrieve any Address Book entries that were not created on the date specified.

{
  "CreationDate":{
    "$NE":"2014-01-01"
  }
}

$GE and $LE

  • Available Since API Version – Not yet implemented

The $GE operator is used for doing searches for values that are greater than or equal to the specified value, and the $LE operator is used for doing searches for values that are less than or equal to the specified value.

Supported Field Types

The $GE and $LE operators are supported for the following field types for most entity types.

Certain entity types may contain some fields that do not support all available search operators. If you try to search on a field using an unsupported operator, the response will contain an error message indicating that the operator is unsupported for that field.

  • CurrencyField
  • DateTimeField
  • NumericField

Examples

The examples below illustrate how to use the $GE and $LE operators when constructing a search query.

$GE Example With NumericField

The following is an example of a $GE search which would retrieve any entries for which the numeric user-defined field with Type_Id 111 has a value greater than or equal to zero.

{     
  "Udf/$TYPEID(111)":{      
    "$GE":0     
  }   
}

$LE Example With DateField

The following is an example of an $LE search which would retrieve any entries that were created on or before the specified date and time.

{
  "CreationDate":{
    "$LE":"2014-01-01T12:00:00"
  }
}

$GT and $LT

  • Available Since API Version – Not yet implemented

The $GT operator is used for doing searches for values that are larger than the specified value, and the $LT operator is used for doing searches for values that are smaller than the specified value.

Supported Field Types

The $GT and $LT operators are supported for the following field types for most entity types.

Certain entity types may contain some fields that do not support all available search operators. If you try to search on a field using an unsupported operator, the response will contain an error message indicating that the operator is unsupported for that field.

  • CurrencyField
  • DateTimeField
  • NumericField

Examples

The examples below illustrate how to use the $GT and $LT operators when constructing a search query.

$GT Example With NumericField

The following is an example of a $GT search which would retrieve any entries for which the numeric user-defined field with Type_Id 111 has a value greater than zero.

{
  "Udf/$TYPEID(111)":{
    "$GT":0
  }
}

$LT Example With DateField

The following is an example of an $LT search which would retrieve any entries that were created before the specified date and time.

{
  "CreationDate":{
    "$LT":"2014-01-01T12:00:00"
  }
}

$IN, $NIN, and $ALL

  • Available Since API Version – 2.7

The $IN, $NIN, and $ALL operators are used for doing searches on tablevalued fields. The $IN operator will return entries where any of the specified values match, the $NIN operator will return entries where none of the specified entries match, and the $ALL operator will only return entries where all of the specified values match.

Supported Field Types

The $IN, $NIN, and $ALL operators are supported for the following field types for most entity types.

Certain entity types may contain some fields that do not support all available search operators. If you try to search on a field using an unsupported operator, the response will contain an error message indicating that the operator is unsupported for that field.

  • EnumField

Examples

The examples below illustrate how to use the $IN and $ALL operators when constructing a search query.

$IN Example With EnumField

The following is an example of an $IN search which would retrieve any entries for which item 1, item 3, or item 5, or any combination of those items are selected for the user-defined table field with Type_Id 123.

{
  "Udf/$TYPEID(123)":{
    "$IN":[
      "1",
      "3",
      "5"
    ]
  }
}

$NIN Example With EnumField

The following is an example of an $NIN search which would retrieve any entries for which item 1, item 3, or item 5, or any combination of those items are not selected for the user-defined table field with Type_Id 123.

{
  "Udf/$TYPEID(123)":{
    "$NIN":[
      "1",
      "3",
      "5"
    ]
  }
}

$ALL Example With EnumField

The following is an example of an $ALL search which would retrieve any entries for which item 1, item 3, and item 5 are all selected for the user-defined table field with Type_Id 123.

{
  "Udf/$TYPEID(123)":{
    "$ALL":[
      "1",
      "3",
      "5"
    ]
  }
}

$LIKE and $NLIKE

  • Available Since API Version – 2.7

The $LIKE and $NLIKE operators are used for doing wildcard comparisons against string-valued fields. The function of the $LIKE operator is similar to that of the "LIKE" operator in a SQL query, and similar wildcards are used.

Supported Field Types

The $LIKE and $NLIKE operators are supported for the following field types for most entity types.

Certain entity types may contain some fields that do not support all available search operators. If you try to search on a field using an unsupported operator, the response will contain an error message indicating that the operator is unsupported for that field.

  • StringField

Supported Wildcards

The $LIKE and $NLIKE operators will accept the following wildcards:

  • % - Matches any sequence of zero or more characters.
  • _ - Matches any single character.

Examples

The examples below illustrate how to use the $LIKE operator when constructing a search query.

$LIKE Example With StringField

The following is an example of an $LIKE search on the CompanyName field that would retrieve any Address Book entries having a Company Name beginning with the letters "ABC".

{
  "CompanyName":{
    "$LIKE":"ABC%"
  }
}

$PHRASE

  • Available Since API Version – 2.4

The $PHRASE operator is a special unary comparison operator that accepts only a search phrase and searches for the supplied phrase within a fixed set of fields.

The functionality of the $PHRASE operator is identical to the quick search bar in Maximizer Web Access. When you use the $PHRASE operator, any AbEntry objects with a matching FirstName, LastName, or CompanyName value are returned.

The $PHRASE operator also matches partial names that start with the search phrase. For example, searching for the name “John” would retrieve entries named “John Adams”, “Samantha Johnston”, and “Johnson Brothers Co”.

You can also use the $PHRASE operator to search for AbEntry objects by email address or phone number. If you supply all or part of an email address containing an @ symbol as the operand for the $PHRASE operator, all AbEntry objects with a matching email address are returned. Similarly, if you supply all or part of a numeric phone number as the operand, all AbEntry objects with a matching phone number are returned.

Examples

The example below illustrates how to use the $PHRASE operator when constructing a search query.

$PHRASE Example

The following is an example of an $PHRASE search which would retrieve any AbEntry objects for which the FirstName, LastName, or CompanyName field starts with the phrase "John".

{
  "$PHRASE":"John"
}

$RANGE and $NRANGE

  • Available Since API Version – 2.7

The $RANGE and $NRANGE operators are used for doing searches for values that fall within or outside a specified range in numeric or date fields.

Supported Field Types

The $RANGE and $NRANGE operators are supported for the following field types for most entity types.

Certain entity types may contain some fields that do not support all available search operators. If you try to search on a field using an unsupported operator, the response will contain an error message indicating that the operator is unsupported for that field.

  • CurrencyField
  • DateTimeField
  • NumericField

Examples

The examples below illustrate how to use the $RANGE and $NRANGE operators when constructing a search query.

$RANGE Example With NumericField

The following is an example of a $RANGE search which would retrieve any entries for which the numeric user-defined field with Type_Id 111 has a value between 1000 and 10000 (inclusive).

{
  "Udf/$TYPEID(111)":{
    "$RANGE":[
      "1000",
      "10000"
    ]
  }
}

$NRANGE Example With DateField

The following is an example of an $NRANGE search which would retrieve any entries for which the CreationDate of the entry is not within the specified date range.

{
  "CreationDate":{
    "$NRANGE":[
      "2013-01-01",
      "2014-01-01"
    ]
  }
}