Operators
  • 03 Jun 2024
  • Dark
    Light
  • PDF

Operators

  • Dark
    Light
  • PDF

Article summary

Equal / Not equal

  • $eq specifies equality condition.
  • $ne operator returns all the items that do not match the specified value.
 {
  "resource": "items",
  "filter": {
    "createdAt": { "$eq": "2019-06-17T23:29:15.775Z" } // Match items that were created at the specified date
  }
}

Greater / Lower Than

  • $gt operator returns all items where the field value is greater than the specified value.
  • $lt operator returns all items where the field value is less than the specified value.
{
  "resource": "items",
  "filter": {
    "createdAt": { "$gt": "2019-06-17T23:29:15.775Z" } // Match items that were created after the specified date
  }
}

Logical AND / OR

  • $or operator specifies a list of expressions and matches all items that satisfy at least one of the expressions that may contain operators.
  • $and operator specifies a list of expressions and matches of all items that satisfy all of the expressions that may contain operators.

In this example, you will get items who have both box annotations and 'car' label.

"join": {
    "filter": {
        "$and": [
            {
                "type": "box"
            },
            {
                "label": "car"
            }
        ]
    },
    "on": {
        "resource": "annotations",
        "local": "itemId",
        "forigen": "id"
    }
}

Read more about 'join' filters here.

Field List Matching

$in operator specifies a list of values and matches all items where the field value matches one of the values.

In this example, you will get items that have annotations created by either "annotator1@dataloop.ai" or "annotator2@dataloop.ai".

{
    "join": {
        "filter": {
            "$and": [
                {
                    "creator": {
                        "$in": [
                            "annotator1@dataloop.ai",
                            "annotator2@dataloop.ai"
                        ]
                    }
                }
            ]
        },
        "on": {
            "resource": "annotations",
            "local": "itemId",
            "forigen": "id"
        }
    }
}

Read more about 'join' filters here.

Wildcards

Wildcards '*' and '?' are supported in field value

  • * Will match zero or more characters.
  • ? Will match one character at most.

Example:

// Match all filenames that contains magic

{ "filename": "*magic*" }

//Match mimetypes image/jpg and image/jpeg

{ "filename": "*jp?g" }