Queries¶
Built in query types¶
These can be used in searches, as in
c.search(FullText("hello"))
|
Query binary comparison between given key's value to the specified value. |
|
Query where a given key's value contains the specified value. |
|
Query equality of a given key's value to the specified value. |
|
Query inequality of a given key's value to the specified value. |
|
Search the full text of all metadata values for word matches. |
|
Query if a given key's value is present in the specified list of values. |
|
Query if a given key's value is not present in the specified list of values. |
|
Match a key's value to a regular expression. |
Query expressions¶
The Key
object can be used to construct queries in a readable way using
standard Python comparison operators, as in
Key("color") == "red"
Key("shape") != "circle"
Key("temperature") > 300
used in searches like
c.search(Key("color") == "red").search(Key("shape") != "circle").search(Key("temperature") > 300)
Notice that, to compound searches, you may use repeated calls to .search()
as in
c.search(...).search(...).search(...)
Warning
You cannot use queries with the Python keywords not
, and
, or or
.
In Python, and
and or
have a particular behavior:
>>> 3 or 5
3
>>> 3 and 5
5
which would result in the first or last query being used, respectively,
ignoring all others. This is an unavoidable consequence of Python semantics.
Likewise, not X
must return True
or False
; it cannot return a query.
To avoid confusion, Tiled raises a TypeError
if you attempt to use
a query with not
, and
, or or
.
|
Compare a key in the metadata to a value using standard Python operators. |