Using Wildcards

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide
ft:sourceType
Paligo

To enable search using non-specific criteria, AQL supports wildcards in common search functions.

Use Wildcards with $match and $nmatch

When using the "$match" and "$nmatch" operators, the "*" wildcard replaces any string and the "?" wildcard replaces a single character.

"Catch all" Notation on Properties

In addition to supporting "$match" and "$nmatch", AQL supports a notation that uses wildcards to match any key or any value on properties.

If you specify "@*" as the property key, then it means a match on any key.

If you specify "*" as the property value, then it means a match on any value

Element

Description

Example

Find items that have any property with a value of "GPL"

Regular notation

items.find({"$and" : [{"property.key" : {"$eq" : "*"}}, {"property.value" : {"$eq" : "GPL"}}]})

Short notation

items.find({"@*":"GPL"})

Element

Description

Example

Find any items annotated with any property whose key is "license" (i.e. find any items with a "license" property)

Regular notation

items.find({"$and" : [{"property.key" : {"$eq" : "license"}}, {"property.value" : {"$eq" : "*"}}]})

Short notation

items.find({"@artifactory.licenses":"*"})

Be careful not to misuse wildcards

Wildcard characters ("*" and "?") used in queries that do not conform to the above rules are interpreted as literals.

Examples of Wildcard Usage

To avoid confusion, here are some examples that use the "*" and "?" characters explaining why they are interpreted as wildcards or literals.

Query

Wildcard or Literal

Explanation

What the query returns

items.find({"name":{"$match":"ant-1.9.4.*"}})

Wildcard

Wildcards on fields are allowed with the $match operator.

All items whose name matches the expression "ant-1.9.4.*"

items.find({"name":{"$eq":"ant-1.9.4.*"}})

Literal

Wildcards on fields are only allowed with the $match and $nmatch operators.

Only find items whose name is literally "ant-1.9.4.*"

items.find({"@artifactory.licenses":"*"})

Wildcard

For properties, this short notation is allowed and denotes any value

All items with a property whose key is "license"

items.find({"@artifactory.licenses":"*GPL"})

Literal

This is the short notation replacing the $eq operator for properties, but it does not use the "catch all" notation for properties.

All items with a license whose value is literally "*GPL"

items.find({"@artifactory.licenses":{"$match":"*GPL*"}})

Wildcard

Wildcards on properties are allowed with the $match operator.

All items with a license matches the expression "*GPL*"