Difference between revisions of "Search Language"

From JRiverWiki
Jump to: navigation, search
(Modifiers)
(43 intermediate revisions by 8 users not shown)
Line 1: Line 1:
This section describes the various rules and modifiers available in the search bar, in the Build New Smartlist dialog box, and in View Scheme creation.
+
Media Center includes a rich and powerful [http://en.wikipedia.org/wiki/Query_language query language] which can be used to perform advanced searches.  This system is the core of the [[Smartlist]] and [[Media Views]] systems in Media Center.  This language is used to query the [[Library]] wherever you search for or filter files.  Media Center provides a powerful wizard that can help you to build your search in an easy-to-understand and graphical manner.  However, this graphical tool simply builds the search using the query language behind the scenes for you and then applies it.  In all cases, you can instead write the query yourself using the full power of the Search Language if you need more flexibility than the graphical tool provides.
  
If you already know the exact search term or abbreviation (see the list below), you can type those in without having to use the Search Wizard.
+
== Searching ==
 +
Before getting too detailed, it is essential to have a basic understanding of how a query works in Media Center.  Being at its core a database, the Media Center library maintains information (or properties) for each file (e.g. audio tracks, image files, video files, etc.) that has been imported.
  
The following is a list of all Rules, Modifiers and Keywords in alphabetical orderThis does not include any custom fields you may have created, nor does it include any expressions (these are listed at the [[J River Developer Webpage]]).
+
Conceptually, when performing a query, Media Center tests a search phrase against each file in the libraryIf the search phrase evaluates to ''true'' for the file, the file is included in the final file list; otherwise, it is not.
  
Items in '''bold''' are modifiers, rather than database fields.
+
A search phrase may be one or more search terms.  Each search term, in order, is tested against every file in the current file list.  The basic idea is that of filtering.  From the list of all imported files, a initial search term reduces the list, and additional search terms further narrows the results to produce a final list of matching files.
  
Note: the list of abbreviations that can be used for a rule is displayed in Tools > Options > LibrarySelect a library field and then select Edit. The abbreviation is listed in the Keywords field.  
+
Queries can generally test any file properties, or even test the results from an evaluated expressionSo long as the query produces a ''true'' value (a value of 1), the file will be included.
  
{| border="1"
+
Queries are used or input in numerous places throughout Media Center - they are the heart of what drives file list production used to populate Views (panes and categories values, file lists) and Smartlists, or via Search to narrow the list of files presented in the current view.  Queries can be entered in the Search bar using Text or Wizard mode, the Edit Smartlist dialog box, and in any ''Set rules for file display'' dialog available in view customization (Standard View, Theater View, Gizmo/WebGizmo, Media Network's DLNA server).
|-valign="top"
 
!Name
 
!Keywords/Abbrev(1)
 
!Example
 
|-valign="top"
 
|Access Rating
 
|accessrating
 
|[Access Rating]=PG-13
 
|-valign="top"
 
|Album
 
|album= or al=
 
|al=[Highway 61" finds all albums that being with Highway 61
 
|-valign="top"
 
|Album Artist
 
|albumartist=
 
|albumartist=Various
 
|-valign="top"
 
|Album Artist (auto)
 
|autoalbumartist=
 
|autoalbumartist=Various  This will return all album artist fields manually entered
 
  
autoalbumartist=multiple This returns all multiple artists if it’s a mix cd (determined automatically).
+
A simple query might test some value against the contents of a specific property, such as the name of an album, a date, or episode number.  For example, the following search phrase:
|-valign="top"
 
|Album Gain
 
|albumgain= or ag=
 
|ag=<2
 
|-valign="top"
 
|Album Type
 
|albumtype=
 
|[Album Type]=[Single artist (complete)]
 
|-valign="top"
 
|Artist
 
|artist= or ar=
 
|ar="Bob Dylan" finds the exact phrase
 
|-valign="top"
 
|Artist – Album (Year)
 
|n/a
 
|[Artist – Album (year)]=[Lilac Time – And Love for All (1990)]
 
|-valign="top"
 
|Band
 
|band= or bd=
 
|bd=Lilac Time
 
|-valign="top"
 
|Bit Depth
 
|n/a
 
|[Bit Depth]=<16
 
|-valign="top"
 
|Bitrate
 
|bitrate=
 
|bitrate=198
 
|-valign="top"
 
|Bookmark
 
|n/a
 
|
 
|-valign="top"
 
|BPM (beats per min)
 
|bpm=
 
|bpm=130 <br>
 
bpm=<130 (smaller than 130)
 
|-valign="top"
 
|Channels
 
|n/a
 
|
 
|-valign="top"
 
|Comment
 
|comment= or c=
 
|comment="live at the Horseshoe"
 
|-valign="top"
 
|Complete Album
 
|completealbum=
 
|completealbum==0 returns incomplete albums and completealbum==1 returns complete albums.
 
note: a complete album has sequentially numbered tracks, from 1 to n.
 
|-valign="top"
 
|Composer
 
|composer=
 
|composer=mozart
 
|-valign="top"
 
|Compression
 
|n/a
 
|
 
|-valign="top"
 
|Content Distributor
 
|cdistrib=
 
|
 
|-valign="top"
 
|Content ID
 
|cid=
 
|
 
|-valign="top"
 
|Content Type
 
|ctype=
 
|
 
|-valign="top"
 
|'''Database Location'''
 
|~d
 
|rock ~d=c searches CD database only for ‘rock’.<br>
 
rock ~d=mt searches main and temporary databases.<br>
 
rock ~d=mct searches main, CD and temporary databases.
 
|-valign="top"
 
|Date
 
|date-=, d=
 
|date=<1y (less than 1 year ago)<br>
 
date=>3m (more than 3 months ago)<br>
 
You can use y (year), d (days) h (hours) m (minute) or s (seconds).
 
|-valign="top"
 
|Date (day)
 
|n/a
 
|[Date (day)]=31
 
|-valign="top"
 
|Date (filename friendly)
 
|n/a
 
|[Date (filename friendly)]=[20040521-174844]
 
|-valign="top"
 
|Date (month)
 
|n/a
 
|[Date (month)]=May
 
|-valign="top"
 
|Date (year)
 
|year=
 
|year=1973 or year==0 (for 0 without returning 2000)
 
|-valign="top"
 
|Date Created
 
|n/a
 
|[Date created]=<1d (today), or [Date Created]=<30m (less than 30 minutes ago). You can use y (year), d (days) h (hours) m (minute) or s (seconds).
 
|-valign="top"
 
|Date Imported
 
|dateimported=
 
|dateimported=<=6d  (last 6 days)<br>
 
dateimported=30h-60h (imported between 30 and 60 hours ago)<br>
 
dateimported=<1y (within the last year.<br>
 
You can use y (year), d (days) h (hours) m (minute) or s (seconds).
 
|-valign="top"
 
|Date Modified
 
|n/a
 
|[Date Modified]=<30m (less than 30 minutes). You can use y (year), d (days) h (hours) m (minute) or s (seconds).
 
|-valign="top"
 
|Dimensions
 
|n/a
 
|
 
|-valign="top"
 
|Disc #
 
|n/a
 
|
 
|-valign="top"
 
|'''Duplicates'''
 
|~dup= or ~nodup=
 
|~dup=[name],[artist] only keeps files in a list when at least one other file has the same name and artist in the list. You can add as many fields as you like (e.g., duration, album, etc).<br>
 
~nodup=[name],[artist] keeps one copy of files that have duplicates.
 
|-valign="top"
 
|Duration
 
|length= or duration=
 
|duration=300    nb-duration is in seconds<br>
 
length=>300 returns all files with a duration greater than 300 seconds
 
|-valign="top"
 
|Events
 
|events=
 
|
 
|-valign="top"
 
|File Size
 
|size=
 
|size=>7000    (size is in kbs)
 
|-valign="top"
 
|File Type
 
|Filetype=
 
|Filetype=mp3
 
|-valign="top"
 
|Filename
 
|filename= or location=
 
|location=D:\Music\Various\
 
|-valign="top"
 
|Filename (name)
 
 
|[Filename (name)]=Train to Prague
 
|-valign="top"
 
|Filename (path)
 
|
 
|[Filename (path)]=photo<br>
 
[Filename (path)]=C:\My Music
 
|-valign="top"
 
|'''Fill'''
 
|~fill
 
|~fill or ~fill=[My ipod name] or ~fill=[D:\] How do you specificy a CD drive? Just the drive name?
 
This modifier limits the number of files returned based on the amount of empty space left on the default or specified device.
 
|-valign="top"
 
|'''Full Albums'''
 
|~a
 
|~a desolation row<br>
 
Returns all albums on which “desolation row” is a trackIf the track is on three albums, then all tracks from all three albums are returned.
 
|-valign="top"
 
|Genre
 
|genre= or g=
 
|g=rock
 
|-valign="top"
 
|Height
 
|height=
 
|height=>100
 
|-valign="top"
 
|Image File
 
|imagefile=
 
|imagefile=adams returns all images containing the word adams in its name. imagefile=[ ] returns files that have no images.
 
|-valign="top"
 
|Insensity
 
|intensity=
 
|intensity=3 or intensity=>2 (values from 1 to 5)
 
|-valign="top"
 
|Keywords
 
|keyword= or keywords= or kw=
 
|kw =poprock;1979;hits (values: semicolon delimited list)
 
|-valign="top"
 
|Last Played
 
|lastplayed=
 
|lastplayed=<24h (less than 24 hours)<br>
 
lastplayed=<30m (less than 30 minutes) <br>
 
You can use y (year), d (days) h (hours) m (minute) or s (seconds).
 
|-valign="top"
 
|'''Limit'''
 
|~limit
 
|~limit=Limit_Total_Keys,Limit_Per_Key,Key_Fields<br>
 
eg All rock, all artists, and of those artists, play no more than 2 songs by any artist:<br>
 
[genre]=[rock] ~limit=-1,2,[artist]<br>
 
Note: -1 means Unlimited.
 
|-valign="top"
 
|'''Limit to n tracks'''
 
|~n
 
|~n=10  returns 10 random tracks.<br>
 
~n=10 Bob Dylan returns 10 tracks containing the words Bob and Dylan.
 
|-valign="top"
 
|Lyrics
 
|lyrics=
 
|lyrics="you know your problem"
 
|-valign="top"
 
|Media Type
 
|mediatype=
 
|mediatype=image
 
|-valign="top"
 
|'''Mix'''
 
|~mix
 
|g=rock ~mix=100,50%,{[Rating]=>3},50%,{[Rating]=<1}<br>
 
play a mix of rock songs, ½ rated 4,5, and ½ unrated.
 
|-valign="top"
 
|'''Mix Album'''
 
|mixalbum=
 
|
 
|-valign="top"
 
|Name (Title)
 
|name= or title= or n=
 
|name="Tangled up in blue"
 
|-valign="top"
 
|Notes
 
|notes=
 
|notes=”conducted by Jeremy”
 
|-valign="top"
 
|Number of Plays
 
|numberplays=
 
|numberplays=>10  returns all files played more than 10 times
 
|-valign="top"
 
|or
 
|or
 
|Extends the search: "Bob Dylan" or "Judy Collins"
 
|-valign="top"
 
|Peak Level
 
|peaklevel=
 
|peaklevel=.77
 
|-valign="top"
 
|People
 
|people=
 
|people=mom,dad,Mike displays all photos that are of one of these people
 
|-valign="top"
 
|Places
 
|places=
 
|places=Amsterdam,London,cottage
 
|-valign="top"
 
|Playback Range
 
|playbackrange=
 
|
 
|-valign="top"
 
|Playlist
 
|playlist= or p=
 
|p="top 40 1996"
 
|-valign="top"
 
|Rating
 
|rating= or r=
 
|rating=3, or rating=5,4
 
|-valign="top"
 
|Removable
 
|removable=
 
|Returns info on files that are on removable media, like a CD or DVD. This new command replaces [Filename}=[Ox” from Media Jukebox.
 
|-valign="top"
 
|Replay Gain
 
|replaygain= or rg=
 
|rg= -16
 
|-valign="top"
 
|Sample Rate
 
|n/a
 
|
 
|-valign="top"
 
|Service: Album Price
 
|n/a
 
|
 
|-valign="top"
 
|Service: Track Price
 
|n/a
 
|
 
|-valign="top"
 
|'''Sort'''
 
|sort=
 
|~sort=[Year],[track #]
 
|-valign="top"
 
|Text
 
|n/a
 
|
 
[Text]=”lemongrass chicken”
 
|-valign="top"
 
|Track #
 
|tracknumber= or t=
 
|t=4  returns all track numbers with 4 (4, 14, 24)<br>
 
t==4 returns only tracks which equal 4.
 
|-valign="top"
 
|Volume Name
 
|volume=
 
|volume="Music 29"  (insert name of your CD)(2))
 
|-valign="top"
 
|Width
 
|width=
 
|width=>80
 
|-valign="top"
 
|Year – Album
 
|
 
|
 
|}
 
  
(1) This field is customizable. To go Tools > Options > Library, select the field and press Edit. Type the abbreviation you would like to use in the Keywords box. You can enter multiple keywords; just separate them with a semi-colon (and no space).
+
:<span style="font-family: Consolas, monospace;">[Album]=Pina</span>
  
(2) This field is best used in conjunction with the ~d parameter, which specifies the database in which to searchNormally, the volume parameter will be relevant in the CD database. See ~d in the table called "Special Modifiers" for more information
+
queries all files asking if the Album property contains the exact sequence of (case-insensitive) letters ''pina''Files that match are included in the resulting list; non-matching files are excluded.
  
==Special Modifiers, Functions and Expressions==
+
Compound queries may be constructed by adding additional search terms, thus testing additional properties.  Multiple search terms are combined by an implicit '''and''' operator.  So it follows that the search phrase:
  
For functions and expressions, see http://www.jrmediacenter.com/DevZone/DBExpressions.htm
+
:<span style="font-family: Consolas, monospace;">[Name]=Midnight [Artist]=Thelonious</span>
{| border="1"
+
 
|-valign="top"  
+
queries all files whose Name contains ''Midnight'' and from those, queries the current list to test that the Artist property contains ''Thelonious''.
!
+
 
!Explanation
+
Generally, any library field may be used in a query; see the Media Center [[File_Properties_%28tags%29|File Properties]] document for a list of the standard properties, and see Options > Library & Folders > Manage Library Fields for the complete list, including custom user fields.
!Example
+
 
|-valign="top"  
+
Keep in mind that the order of the files returned from a query is generally undefined or random.  Sorting is done by the view, or specifically by other query constructs such as Modifiers.
|" "
+
 
|exact match & multi-word search
+
The next few sections describe the available operators available to construct search queries from simple to complex.  Following that will be a description of search query [[#Modifiers|Modifiers]].
|"Bob Dylan"  "Desolation Row"
+
 
|-valign="top"  
+
== Comparison Operators ==
|( )
+
The query language provides the standard comparison operators of equal-to, less-than, less-than/equal-to, greater-than and greater-than/equal-to.  These allow defining a search term to compare a specified ''value'' against a given ''field'' (also called ''property'').
|exact match & multi-word search
+
 
|"Bob Dylan" (1966 or 2001)
+
For fields of type Date, values may include units such as '''d''', '''w''', '''y''', '''h''', '''m''' and '''s''' to indicate ''day'', ''week'', ''month'', ''year'', ''hour'', ''minute'', and ''second'' respectively. Floating point values may be used (e.g. .5w for 1/2 week).
returns an exact match on Bob Dylan, AND an exact match on 1966 and another on 2001.
+
 
( ) are used as in a math equation.  Example:
+
When comparing the values of 0 and empty, it is important to understand how Media Center both stores and displays these values for the numeric and string datatypes.  A 0 value for numeric types will be displayed in Media Center as empty, whereas for string types, as a 0.  When comparing against numeric values, both 0 and empty [] are considered equivalent and either may be used.  For string types, the 0 and empty values are distinct.
r=4,5 (genre=rock or year=1970-1980)  
+
 
is much different from
+
Note: For numeric types, the value of 0 is stored as a 0 internally, but Media Center uses a formatted display version of the field and shows it as an empty value.  For example, if the field [My Integer Field] is set with the value of 0, it will show in a pane column or cell as empty.  To see the actual value stored, use an expression column with the raw format field specifier ''',0''' in the field name just before the closing bracket: [My Integer Field,0].  Media Center typically uses the formatted version of the field, which is expressed as [My Integer Field,1], where the ''',1''' is the optional default.
r=4,5 genre=rock or year=1970-1980.
+
 
|-valign="top"  
+
{| border="0"
|[ "
+
|- valign="top"  
|exact beginning
+
!   width="120"  | Operator
(don't forget the " at the end of entry)
+
!   align="left" | Description
|[Stan"
+
 
returns everything beginning with "Stan".
+
|- valign="top"
Stan Getz,  Stand by Me, Standing in the Doorway
+
|   align="center" | <span style="font-family: Consolas, monospace;">''field'''''='''''value''</span>
|-valign="top"  
+
| Equal to the specified ''value''.
|" ]
+
 
|exact ending
+
Example: Return all files whose Artist field contains ''smith'' anywhere.
(don't forget the " at beginning of entry)
+
 
|"stand]
+
<span style="font-family: Consolas, monospace;">
returns everything that ends with "stand".
+
[Artist]=Smith
Stand, I Will Stand, I Didn't Understand.
+
</span>
|-valign="top"  
+
 
|[ ]
+
|- valign="top"
|begins & ends exactly as indicated
+
|   align="center" | <span style="font-family: Consolas, monospace;">''field'''''=<'''''value''
|[Bob Dylan],  [Desolation Row]
+
| Less than the specified ''value''.
The results will exclude Bob Dylan & the Band because this entry does not end with Dylan.
+
 
|-valign="top"  
+
Example: Return all files imported within the last 1/2 day (12 hours):
|,
+
 
|comma, delimits lists
+
<span style="font-family: Consolas, monospace;">
|artist="Bob Dylan",[Sting],Merlin
+
[Date Imported]=<.5d
This returns all tracks from these three artists. Do not insert spaces.   
+
</span>
|-valign="top"  
+
 
|-
+
|- valign="top"
|exclude search term
+
|   align="center" | <span style="font-family: Consolas, monospace;">''field'''''=<='''''value''
|"Bob Dylan" -album=([time",[blood","mercy]) –year=1993
+
| Less than or equal to the specified ''value''.
returns an exact match on Bob Dylan, except for albums beginning with "Time" and "Blood", ending with mercy, and excluding tracks from 1993.
+
 
|-valign="top"  
+
Example: Return all files that are rated less than or equal to 2:
|and
+
 
|narrow the search
+
<span style="font-family: Consolas, monospace;">
|"Bob Dylan" and "the Band"
+
[Rating]=<=2
Note: the "and" is assumed whenever you type in many words, so it is not necessary to include it.
+
</span>
|-valign="top"  
+
 
|or
+
|- valign="top"  
|extend the search
+
|   align="center" | <span style="font-family: Consolas, monospace;">''field'''''=>'''''value''
|"Bob Dylan" or "Judy Collins"
+
| Greater than the specified ''value''.
|-valign="top"  
+
 
|~s
+
Example: Return all files that are rated greater than 3:
|limit to s Megabytes
+
 
|~s=650 returns a random number of tracks totaling a maximum of 650MB.
+
<span style="font-family: Consolas, monospace;">
~s=650 Bob Dylan returns 650MB worth of tracks with Bob and Dylan in any of the fields.
+
[Rating]=>3
|-valign="top"  
+
</span>
|~t
+
 
|limit to t minutes
+
|- valign="top"  
|~t=60 returns 60 minutes of random music.
+
|   align="center" | <span style="font-family: Consolas, monospace;">''field'''''=>='''''value''
|-valign="top"  
+
| Greater than or equal to the specified ''value''.
|<
+
 
|smaller than
+
Example: Return all files whose bitrate is greater than or equal to 256kbps:
|lastplayed=<60  returns tracks played in less than the past 60 minutes.
+
 
|-valign="top"  
+
<span style="font-family: Consolas, monospace;">
|>
+
[Bitrate]=>=256
|greater than
+
</span>
|bitrate=>128 returns tracks with more than 128 bitrate, or
+
|}
rating=>3 returns all tracks rated with 4 or 5.
+
 
|-valign="top"  
+
Take note that the '''=''' character ''always'' follows a field name in comparison operations. In the case of ''equal to'', the equivalence operator is implicitThis can be best illustrated by comparing the following example comparisons operations on the [Date (year)] field:
|~%
+
 
|limits percentage of hits
+
:<span style="font-family: Consolas, monospace;">[Date (year)]'''='''1980</span>
|~%=50 "Bob Dylan" returns 50% of all tracks with Bob Dylan in any field.
+
:<span style="font-family: Consolas, monospace;">[Date (year)]'''='''<1980</span>
 +
:<span style="font-family: Consolas, monospace;">[Date (year)]'''='''<=1980</span>
 +
:<span style="font-family: Consolas, monospace;">[Date (year)]'''='''>1980</span>
 +
:<span style="font-family: Consolas, monospace;">[Date (year)]'''='''>=1980</span>
 +
 
 +
== Quoting and Anchoring ==
 +
 
 +
Certain characters are used by the Media Center query language (e.g. ''<space>'' as the separator for search terms).  To use these characters, they need to be quoted.  Additionally, by default, Media Center queries are free to search anywhere within a given property.  The special constructs listed below provide a means to both quote and anchor search terms.
 +
 
 +
A pair of double quotes '''"''' '''"''' is used to include spaces or special characters in a search phrase.  Replacing the opening quote with an opening bracket '''[''' will anchor the search to the beginning.  Likewise, the closing quote may be replaced with a closing bracket ''']''' to anchor at the end.  Replacing both quotes will fully anchor the search, requiring a full match from beginning to end.  To search for an empty value, use the beginning and end anchored '''[]''' construct.
 +
 
 +
{|  border="0"
 +
|- valign="top"
 +
!  width="120" | Quote/Anchor
 +
!  align="left" | Description
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''"'''''phrase'''''"'''</span>
 +
| Double quotes are used to include spaces or special characters in the search ''phrase''.  The ''phrase'' will match anywhere within a string.
 +
 
 +
Example: Match something that contains the string ''Steve Miller'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
"Steve Miller"
 +
</span>
 +
 
 +
|- valign="top"  
 +
|   align="center" | <span style="font-family: Consolas, monospace;">'''['''''phrase'''''"'''</span>
 +
| Same as double quotes above, but forces the ''phrase'' to match only at the beginning of the string.
 +
 
 +
Example: Match something that starts with ''Stan'', such as ''Stan Getz'', ''Stand by Me'', but not ''One Standard Night'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Stan"
 +
</span>
 +
 
 +
|- valign="top"  
 +
|   align="center" | <span style="font-family: Consolas, monospace;">'''"'''''phrase''''']'''</span>
 +
| Same as double quotes above, but forces the ''phrase'' to match only at the end of the string.
 +
 
 +
Example: Match something that ends with ''stand'', such as ''I Will Stand'', ''I Didn't Understand'', but not ''The Standards'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
"stand]
 +
</span>
 +
 
 +
|- valign="top"  
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''['''''phrase''''']'''</span>
 +
|Same as double quotes above, but forces the ''phrase'' to match both at the beginning and end of the string.
 +
 
 +
Example: Match exactly ''Bob Dylan'' and exclude ''Bob Dylan & the Band'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Bob Dylan]
 +
</span>
 +
 
 +
Example: Match empty values by forcing a match at the beginning and then immediately at the end:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[]
 +
</span>
 +
 
 +
|- valign="top"  
 +
|   align="center" | <span style="font-family: Consolas, monospace;">'''^'''''word''</span>
 +
|Restricts matching to a full word.  A word is broken by space, punctuation, etc.
 +
 
 +
Example: Match ''car'' as a full word, as in ''A Car for All'', but not ''Barcarolle''.
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
^car
 +
</span>
 
|}
 
|}
  
Notes
+
== Grouping and Combining ==
# The "=" sign between the ~n, ~d or ~t and the value is optional (e.g., ~n30 vs. ~n=30 or ~s100 vs. ~s=100)
+
Multiple search terms can be combined to form more complex queries.  Queries are read and evaluated left to rightThe '''and''' and '''or''' operations below are mathematical, and should not be interpreted as common language.  A query of '''A and B''' means that A must be True and at the same time B must be True (common language interpretation could mean one desires items where A is True ''and also'' items where B is True, but this would be an '''or''' operation).
# Quotation marks and brackets must go in pairsFor example, Metallica] is invalid; it must be either [Metallica] or "Metallica] ).
+
 
# When you have an = followed by a numeric value, the search looks for a substring, and so will return all items containing that number. Eg year=0 will return 0, 2000, 2001, 1990. If you want to search for an exact number, use two equal signs: year==0 which will return only those tracks with a year of 0.
+
{| border="0"
 +
|- valign="top"
 +
!  width="120" | Grouping
 +
!  align="left" | Description
  
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">''s1'' '''and''' ''s2''</span>
 +
| Narrows the results returned by requiring matches of both of the search terms ''s1'' and ''s2''.
  
Examples
+
Example: Return all files by artist ''Frank Sinatra'' and orchestra ''Tommy Dorsey'':
  
Here are few examples of the kinds of rules you can create. Note: these examples are for typing the rules directly; you can use the Wizard for much simpler access to rules.
+
<span style="font-family: Consolas, monospace;">
 +
[Artist]="Frank Sinatra" and [Orchestra]="Tommy Dorsey"
 +
</span>
  
   
+
Since the '''and''' operation is implicit between search terms, is it not required. The following search phrase is equivalent to that shown in the example above:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Artist]="Frank Sinatra" [Orchestra]="Tommy Dorsey"
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">''s1'' '''or''' ''s2''</span>
 +
| Expands the results returned by accepting matches of either (or both) of the search terms ''s1'' or ''s2''.
 +
 
 +
Example: Return all files named ''Spying Glass'' or named ''Angel'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Name]=[Spying Glass] or [Name]=[Angel]
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''('''''s1 or s2''''')'''</span>
 +
| Groups search terms to force precedence when using multiple search terms with the '''and''' and the '''or''' operators.
 +
 
 +
Example: Return all files whose artist is exactly ''Bob Dylan'' and whose year is either ''1966'' or ''2001'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Artist]=[Bob Dylan] ([Date (year)]=1966 or [Date (year)]=2001)
 +
</span>
 +
 
 +
Note the distinction of the example above with the following example:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Artist]=[Bob Dylan]  [Date (year)]=1966 or [Date (year)]=2001
 +
</span>
 +
 
 +
The first example uses grouping parenthesis to force the order of evaluation, and returns files from Bob Dylan as the artist, from the year 1966 or 2001.  The second example, due to order of evaluation from left to right, returns files with Bob Dylan as the artist from the year 1966, and also returns all files with year 2001.
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">''val1''''','''''val2''</span>
 +
| Combines two or more values into a list, identical to the '''or''' operator.  No spaces are allowed between the comma(s) and the values.
 +
 
 +
Example: Return all files whose artist is any of ''Queen'', ''Heart'', or the ''Grateful Dead'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
artist=[Queen],[Heart],"Grateful Dead"
 +
</span>
 +
 
 +
The search phrase in the example above is identical to the more cumbersome:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
([Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead")
 +
</span>
 +
|}
 +
 
 +
== Negation and All ==
 +
 
 +
{|  border="0"
 +
|-  valign="top"
 +
!  width="120"  | Operator
 +
!  align="left" | Description
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''-'''''field''</span>
 +
| Inverts the sense of the comparison, returning those files whose ''field'' does not match the specified value.  Usage is limited to the equality and comparison operators.
 +
 
 +
Example: Return all files whose track number is not 1:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
-[Track #]=1
 +
</span>
 +
 
 +
Example: Return all files whose track number is not greater than or equal to 3:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
-[Track #]=>=3
 +
</span>
 +
 
 +
Note that this equivalent to the more direct search phrase:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Track #]=<3
 +
</span>
 +
 
 +
Example: Return all files by artist ''Mark Isham'', except those whose album names begin with ''after'' or ''quiz'', or end with ''home'', and exclude files from ''1993'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Artist]="Mark Isham" -[Album]=[after",[quiz","home] -[Date (year)]=1993
 +
</span>
 +
 
 +
Example: Return all files that have associated artwork (i.e. [Image File] is not empty).
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
-[Image File]=[]
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''+'''''field''</span>
 +
| Forces matching all of the specified terms (useful for matching against list types).  Usage is limited to the equality operator.
 +
 
 +
Example: Return all files with keywords ''Smith'' and ''Jones'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
+[keywords]=[Smith],[Jones]
 +
</span>
 +
 
 +
Example: Return all files with both of the artists '' Alison Krauss'' and ''Robert Plant'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
+[Artist]=[Alison Krauss],[Robert Plant]
 +
</span>
 +
|}
 +
 
 +
== Modifiers ==
 +
 
 +
Queries and results can be modified by using one or more of the following special modifiers.  Some modifiers act globally on, or affect the context of, the query, while others operate on the results returned as the query is being processed from left-to-right.
 +
 
 +
Some complex queries with modifiers will require manual entry in the '''Search Rules Importer/Exporter''' dialog available via the '''Import/Export''' button.  The '''Edit Search''' wizard forces modifiers to the end of the query, thus removing the left-to-right processing required for certain modifiers such as '''~seq''' or '''~sort'''.  Hint: always copy your complex query before leaving the Importer/Exporter so that it can be pasted again after testing.
 +
 
 +
Some of the modifiers below can operate on one or more fields.  These compound field lists are expressed as a list of comma-separated fields [''field1''],[''field2''],...,[''fieldn''].
 +
 
 +
Note: For single character modifiers (i.e. ~n, ~d, ~s and ~t), the '''=''' character between the modifier and the ''value'' is optional (e.g., '''~n30''' is equivalent to '''~n=30''').
 +
 
 +
{|  border="0"
 +
|-  valign="top"
 +
!  width="120"  | Modifier
 +
!  align="left" | Description
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~d='''''database''</span>
 +
| Selects (limits) the Media Center '''database''' used in the query (e.g. Main, CD, Bad, Removed, etc.).  More than one ''database'' may be specified by combining selectors.
 +
 
 +
; Database selectors
 +
: a = All
 +
: b = Bad (or corrupt files get placed here) [starting w/v16.0.164]
 +
: c = CD (and DVDs)
 +
: e = Explorer
 +
: g = Guide (Television) [starting w/v15.0.160]
 +
: i = Category Images
 +
: m = Main
 +
: r = Removed  [starting w/v15.0.160]
 +
: s = Store
 +
: t = Temporary (Playing Now)
 +
 
 +
Example: Limit the query to the CD and Main databases:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
~d=cm
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~dup='''''fields''</span>
 +
| Returns a list of only duplicate files, where duplicates are determined by comparing the combined values in the specified ''fields'' list.  Duplicate detection is based on matching values in fields, not by examining file content.
 +
 
 +
Example: Return a list of duplicate files by using the [Name] and [Artist] fields as the duplicate detectors:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
~dup=[Name],[Artist]
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~nodup='''''fields''</span>
 +
| Returns a list with duplicate files removed, where duplicates are determined by comparing the combined values in the specified ''fields'' list.  Only one of any duplicate file is included in the list.  Duplicate detection is based on matching values in fields, not by examining file content.
 +
 
 +
Example: Return a list of all files with duplicates removed, by using the [Genre] field as the duplicate detectors.  The returned list include one random file from each genre.
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
~nodup=[Genre]
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~fill'''</span>
 +
| Returns a list of files to fill the specified device to maximum capacity.  This modifier limits the number of files returned based on the amount of empty space left on the default or specified device.
 +
 
 +
Examples:  Fill the default or specified device to maximum capacity:
 +
 
 +
<span style="font-family: Consolas, monospace;">~fill</span>
 +
 
 +
<span style="font-family: Consolas, monospace;">~fill=[D:\]</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~a'''</span>
 +
| Expands the track list (if necessary) to include the remaining tracks from the album(s).
 +
 
 +
Example: Return all tracks containing the name ''Feliz Navidad'', and expand that list to include the remaining tracks in the album(s).  If the track is on three albums, then all tracks from all three albums are returned.
 +
 
 +
<span style="font-family: Consolas, monospace;">[Name]="Feliz Navidad" ~a</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~limit''' ''f''''','''''n''''','''''fields''
 +
</span>
 +
| Limits the set of files to at most ''n'' files from each of at most ''f'' values from the combined ''fields''.  This is easier explained with a simple example.  From there, the general concept should be clearer.
 +
 
 +
Example: Limit the returned files, first by selecting at most 10 unique artists, and from each of those artists, return at most 2 files:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~limit=10,2,[Artist]
 +
</span>
 +
 
 +
First 10 distinct artists will be randomly selected from the list of all possible artists, and then 2 random files from each of those artists will be selected and returned.  If the limit cannot be satisfied (because there are too few artists, or too few files-per-artist), the available artists or files will be returned.  In other words, these values are upper limits.
 +
 
 +
The value of '''-1''' is used to select ''all'' values, and can be used for either ''f'' or ''n''.
 +
 
 +
Example: Return all files from the ''Rock'' genre, but limit those results, first by randomly selecting at most 5 unique album / year pairs, and selecting all files from each of those albums:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:[Genre]=Rock ~limit=5,-1,[Album],[Date (year)]
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~n='''''num''</span>
 +
| Limits to a maximum of ''num'' files.
 +
 
 +
Example: Return at most 20 randomly selected tracks:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~n=20
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~mix='''''n''''','''''s''</span>
 +
| Creates a mix of ''n'' files, according to the rules set by one or more comma-separated mix specifiers ''s''.  The format of each search specifier ''s'' is:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:''val,{criteria}''
 +
</span>
 +
 
 +
and ''val'' is either a number (e.g. 15) or a percentage (e.g. 10%), and ''criteria'' is a standard search phrase.  The overall mix syntax follows the form:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:''~mix=n,val1,{criteria1},val2,{criteria2},...''
 +
</span>
 +
 
 +
The values ''val1'', ''val2'', ... should be either all percentages or all numeric, and should sum to either 100% or to the maximum number of tracks, respectively.  Otherwise, the resulting mix proportions are not clearly defined.
 +
 
 +
Example: Selecting from all ''Rock'' tracks, return a 10-track mixture with a 60/40 percentage split between artists whose names contain Mark or Tom, respectively.
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:[Genre]=Rock ~mix=10,60%,{[Artist]=Mark},40%,{[Artist]=Tom}
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~s='''''num''</span>
 +
| Limits the number of files such that the cumulative size does not exceed ''num'' megabytes.
 +
 
 +
Example: Return a random set of files totaling a maximum of 650MB.
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~s=650
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~sort='''''fields''</span>
 +
| Sorts the list of files by the specified list of ''fields''.
 +
 
 +
Example: Sort the list of files first by date, and then by track number:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~sort=[Date],[Track #]
 +
</span>
 +
 
 +
Sorting is in ascending order by default.  Add '''-d''' to the end of a field to force descending sort order for that field.
 +
 
 +
Example: Sort the list of files first by date imported in reverse order, and then by album:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~sort=[Date Imported]-d,[Album]
 +
</span>
 +
 
 +
Two special sort terms can be used: '''Random''' is used to randomize the order of list of files, and '''[Sequence]''' can be used to sort by the sequence number previously set with the '''~seq''' modifier.
 +
 
 +
Example: Randomize (shuffle) the list of files:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~sort=Random
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~t='''''num''</span>
 +
| Limits the cumulative track time to not exceed the ''num'' minutes.
 +
 
 +
Example: Limit the set of files to a maximum of 60 minutes:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
:~t=60
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~%='''''num''</span>
 +
| Limits the set of files to a maximum of ''num'' percent of the total possible.
 +
 
 +
Example: Randomly select and return 50% of the files imported into Media Center within the last week:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Date Imported]=<1w ~%=50
 +
</span>
 +
 
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~seq'''</span>
 +
| Assigns a monotonically increasing sequence number to the current set of files.  This modifier is useful in a more complex query to return the sort order set earlier.
 +
 
 +
Example: Select all tracks imported in the past 4 weeks, and sort them in descending order by date imported, assign a sequence number to be used later, limit the number of tracks to two per album, and sort based on the sequence number assigned earlier:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
[Date Imported]=<4w ~sort=[Date Imported]-d ~seq ~limit=-1,2,[Album] ~sort=[Sequence]
 +
</span>
 +
|-  valign="top"
 +
|  align="center" | <span style="font-family: Consolas, monospace;">'''~expand='''''fields''</span>
 +
| Expands the included tracks on the given field.
 +
Example: Expand the tracks to the matching genre:
 +
<span style="font-family: Consolas, monospace;">
 +
:~expand=Genre
 +
</span>
 +
 
 +
|}
 +
 
 +
== Search, Search Wizard and More ==
 +
 
 +
The query language has grown over time, and there are several ways to express an identical query.  Where '''Search''' tries to ''do what you mean'' (by searching most fields automatically and presenting a list of possible matches from which to choose), the translation into the '''Search Wizard''' often requires a more specific or precise query.  Also note that the '''Search Wizard''' tends to restructure queries, preferring the less ambiguous, but more pedantic form.  This can result in some queries not translating accurately from Search into Search Wizard.  For example, the loosely written three-term search query using the '''or''' operator
 +
 
 +
:<span style="font-family: Consolas, monospace;">[Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead"</span>
 +
 
 +
will be incorrectly translated by Search Wizard into a three-term '''and''' operation
 +
 
 +
:<span style="font-family: Consolas, monospace;">[Artist]=[Queen] [Artist]=[Heart] [Artist]="Grateful Dead"</span>
 +
 
 +
instead of the correctly grouped search phrase
 +
 
 +
:<span style="font-family: Consolas, monospace;">([Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead")</span>
 +
 
 +
Media Center [[File_Properties_%28tags%29#Predefined_Fields|file properties]] support search keywords, often abbreviations or alternate forms of the property name.  These keywords can be used to specify searching a given field.  For example, the '''[Date (year)]''' field can be specified either by using its full field name '''[Date (year)]''' or by using the '''year=''' search keyword.  As mentioned above, when pushing a query from Search into the Search Wizard, search keywords are translated into the field's full name form.  This can be seen by entering a search keyword into Search, and then entering Search Wizard and using the Import/Export button to examine the full query.
 +
 
 +
== Searching with Expressions ==
 +
 
 +
For richer, more advanced queries, Media Center Search supports using the [[Media_Center_expression_language|Media Center Expression Language]].  Expression-based queries can be entered anywhere a Search query would be used, and as a Custom rule under Edit Search > Rules.  The general syntax for using expressions formed as a query is:
 +
 
 +
:<span style="font-family: Consolas, monospace;">'''[='''''expression''''']='''''value''</span>
 +
 
 +
Media Center will evaluate ''expression'', and compare the result to ''value''.  All files for which the comparison produces a True result will be included in the query results.  The following demonstrative (and utterly useless) queries would return all files:
 +
 
 +
:<span style="font-family: Consolas, monospace;">[=1]=1</span>
 +
:<span style="font-family: Consolas, monospace;">[=math(0 * 2)]=0</span>
 +
 
 +
The equal comparison operator is a string comparison, so the following expression-based search works as expected:
 +
 
 +
:<span style="font-family: Consolas, monospace;">[=Orientation()]=Portrait</span>
 +
 
 +
Currently only the equal operator is supported.  Be sure to properly quote ''value'' when necessary, as mentioned above in [[#Quoting_and_Anchoring|Quoting and Anchoring]].  In the following examples, the first search expression will be True for all files, and the second will be False:
 +
 
 +
:<span style="font-family: Consolas, monospace;">[=math(10 + 1)]=1</span>
 +
:<span style="font-family: Consolas, monospace;">[=math(10 + 1)]=[1]</span>
 +
 
 +
== Search and Locales ==
 +
 
 +
Certain characters such as period and comma are affected by the Windows locale settings.  In some locales, a comma is used for the decimal point.  Since Media Center reads input in the English locale and outputs values in the current locale, this can affect search results in unexpected ways.  Consider the query below.  It tests against the value of 1 or 2 and not the value of 1 point 2:
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
::[My Decimal Field]=1,2
 +
</span>
 +
 
 +
Be sure to format your queries using Media Centers expected input, and that any input or output from expression-based queries are formatted accordingly.
 +
 
 +
== Current Limitations or Bugs ==
 +
 
 +
The following are some of the known limitations and/or bugs with certain queries:
 +
 
 +
1. The values used in the ~mix modifier val1, val2, ... should be either all percentages or all numeric, and should sum to either 100% or to the maximum number of tracks, respectively. Otherwise, the resulting mix proportions are not clearly defined.
 +
 
 +
2. Translations from Search Text to Search Wizard may cause changes in the meaning of the search query. The text entered as:
 +
 
 +
::<span style="font-family: Consolas, monospace;">[Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead"</span>
 +
 
 +
becomes translated incorrectly by Search Wizard into:
 +
 
 +
::<span style="font-family: Consolas, monospace;">[Artist]=[Queen] AND [Artist]=[Heart] AND [Artist]="Grateful Dead"</span>
 +
 
 +
and
 +
 
 +
::<span style="font-family: Consolas, monospace;">[Rating]=1,2</span>
 +
 
 +
becomes
 +
 
 +
::<span style="font-family: Consolas, monospace;">[Rating]=1; 2</span>
 +
 
 +
which then finally becomes
 +
::<span style="font-family: Consolas, monospace;">[Rating]=1 2</span>
 +
 
 +
== Examples ==
 +
 
 +
The following are a few example queries to help solidify your understanding of how to form search queries.  These rules can be copy/pasted into the Search box, and you can use the Search Wizard for more assistance in developing search rules.  Note: some of the examples show variations of the same rule, illustrating the use of full field names or their (keyword) abbreviations. 
 +
 
 +
Example: Files from album names containing ''Greatest Hits'':
 +
 
 +
<span style="font-family: Consolas, monospace;">
 +
::<span style="font-family: Consolas, monospace;">[album]="Greatest Hits"</span>
 +
::<span style="font-family: Consolas, monospace;">al="Greatest Hits"</span>
 +
 
 +
Example: Files imported into Media Center in the past 7 days:
 +
::<span style="font-family: Consolas, monospace;">[Date Imported]=<=7d</span>
 +
::<span style="font-family: Consolas, monospace;">dateimported=<=7d</span>
 +
 
 +
Example: Tracks greater than 5 minutes (300 seconds) in duration (length) that have played in the last 60 minutes, with the results sorted by track length:
 +
 
 +
::<span style="font-family: Consolas, monospace;">Duration]=>300 [Last Played]=<60m ~sort=[Duration]</span>
 +
::<span style="font-family: Consolas, monospace;">length=>300 lastplayed=<60m ~sort=length</span>
 +
 
 +
Example: All mp3 files by any artist whose name begins with ''Joe'':
 +
::<span style="font-family: Consolas, monospace;">[File Type]=mp3 [Artist]=[Joe"</span>
 +
 
 +
Example: Files that are in either the genre Opera or Classical:
 +
::<span style="font-family: Consolas, monospace;">[Genre]=[Opera] or [Genre]=[Classical]</span>
 +
::<span style="font-family: Consolas, monospace;">g=[Opera] or g=[Classical]</span>
 +
::<span style="font-family: Consolas, monospace;">g=[Opera],[Classical]</span>
 +
 
 +
Example: Files from genre names beginning with ''Rock'', where the number of plays is less than 5, and the Artist is neither ''Sting'' nor ''Beatles'', shuffling the results:
 +
::<span style="font-family: Consolas, monospace;">[Genre]=[Rock" [Number Plays]=<5 -[Artist]=Sting,Beatles ~sort=Random</span>
  
genre, bitrate, comment 
+
Example: Ten random files from the "Top 40 1983" playlist which were not played in the last 5 days:
 +
::<span style="font-family: Consolas, monospace;">[Playlist]="Top 40 1983" [Last Played]=>5d ~n=10</span>
 
   
 
   
 +
Example: 60 minutes worth of files rated 3 or higher, sorted randomly:
 +
::<span style="font-family: Consolas, monospace;">~sort=Random [Rating]=>=3 ~t=60</span>
 
   
 
   
      [genre]=[opera] [bitrate]=[320] [comment]="Italian"
+
Example: 100 rock tracks, 50% of which are rated 4 and 5, 25% of which are rated 1 and 2 and 25% unrated:
 +
::<span style="font-family: Consolas, monospace;">g=rock ~mix=100,50%,{[Rating]=>3},25%,{[Rating]=1,2},25%,{[Rating]=[]}</span>
 +
 
 +
Example: 50 tracks, ½ of which are Country Rock, and ½ of which are Alternative Rock:
 +
::<span style="font-family: Consolas, monospace;">~mix=50,50%,{[Genre]=[Country Rock]},50%,{[Genre]=[Alternative Rock]}</span>
 
   
 
   
+
Example: From the opera genre, limit the results to all tracks from seven albums:
Result: Finds all opera files with a bitrate of 320 that include "Italian" in the comment field
+
::<span style="font-family: Consolas, monospace;">[genre]=[opera] ~limit=7,-1,[album]</span>
+
 
duration, last played 
+
Example: One file from each artist, and from those only two files per year:
+
::<span style="font-family: Consolas, monospace;">~limit=-1,1,[Artist] ~limit=-1,2,[Year]</span>
 
      [lastplayed]=<60m [duration]==>300
 
 
 
Result: Finds all tracks that are 5 minutes long or more (300 seconds), and that have played in the last hour (60 minutes)
 
 
image file
 
 
 
      Imagefile=[]
 
 
 
Find all files whose image field is empty (files without images). Placing a minus sign – immediately before Imagefile finds all files that do have imges.
 
 
 
      [Imagefile]=.,\
 
 
 
Finds all tracks with external cover art. Adding – before this expression returns all tracks with cover art stored internally (in the file).
 
 
playlist, last played, limit tracks
 
 
 
      [playlist]="top 40 1983" [lastplayed]=10-30 ~n=10
 
 
 
Result: Finds 10 tracks tracks that are in the "Top 40 1983" playlist that were last played 10-30 minutes ago.
 
 
file size, artist
 
 
 
      [size]=>7000 [artist]=[Bet*
 
 
 
Result: Find all files larger than 7000kbs (or 7MB) whose artist field begins with "Bet"
 
 
exclude, number of plays
 
 
 
      [genre]=[alt* numberplays=>10 -[artist]=Sting,Beatles
 
 
 
Result: Find all genres that begin with "alt", and play all the tracks that have been played more than 10 times, but exclude tracks from Sting and from the Beatles. (Note: To manually type in an exclusion, as in this example, simply put a "-" before the rule.)
 
 
sort, rating, limit time
 
 
 
      ~sort=[Random] [Rating]=>=3 ~t=60
 
 
 
Result: Find 60 minutes worth of files rated 3 or higher and sort them randomly.
 
 
date imported
 
 
 
      [dateimported]=<=7d
 
 
 
Result: Show all files imported in the past 7 days. Note: You can use y (year), d (days) h (hours) m (minute) or s (seconds).
 
 
mix
 
 
 
      g=rock ~mix=100,50%,{[Rating]=>3},25%,{[Rating]=1,2},25%,{[Rating]=[]}
 
 
 
Result: play 100 rock tracks, 50% of which are rated 4 and 5, 25% of which are rated 1 and 2 and 25% unrated.
 
 
 
                ~mix=50,50%,{[Genre]=[Country Rock]},50%,{[Genre]=[Alternative Rock]}
 
 
 
Result: play 50 tracks, ½ of which are Country Rock, and ½ of which are Alternative Rock.
 
 
limit
 
 
 
      [genre]=[rock] ~limit=7,-1,[album]
 
 
 
Result: play only 7 rock albums.
 
  
Explanation: for all rock, find only 7 albums, and play all (-1) tracks from that album.
+
Example: Images from the years 1930 to 1963, limited to 1 random year with the results randomly sorted:
 +
::<span style="font-family: Consolas, monospace;">[Media Type]=[Image] [Date (year)]=1930-1963 ~limit=1,-1,[Year] ~sort=Random</span>
  
The syntax for use with ~limit is:
+
Example: Files with a rating of 4 and that are either in the rock genre or from the year 1970 to 1980 (compare with the next example):
+
::<span style="font-family: Consolas, monospace;">[Rating]=4 ([Genre]=[Rock] or [Date (year)]=1970-1980)</span>
 
      ~limit=LIMIT_TOTAL_KEYS,LIMIT_PER_KEY,KEY_FIELDS
 
 
 
This means: take a key field (e.g., album), limit the total of that field (7 albums, or –1 for unlimited), and of that total, limit again per field (2 tracks per album, or –1 for unlimited)
 
 
 
      ~limit=-1,1,[Artist] ~limit=-1,2,[Decade]
 
 
 
Result: plays 10 tracks, 2 from each of the decades (a custom field) and the same artist appears only once.
 
  
Explanation: The first limit: find unlimited artists (-1), and play only one track per artist (1). The second part means: find all decades (-1) and limit to 2 tracks per decade (2).
+
Example: Files with a rating of 4 and in the rock genre, or files from the year 1970 to 1980 (compare with the previous example):
+
::<span style="font-family: Consolas, monospace;">[Rating]=4 [Genre]=[Rock] or [Date (year)]=1970-1980</span>
 
      [genre]=[rock] ~limit=7,2,[album]
 
 
 
Result: From the rock genre, find 7 albums, and play only 2 tracks per album.
 
  
Explanation: for all rock, limit the total albums to 7, and limit those 7 albums to 2 tracks each.
+
Example: Randomly select 3 songs from one album per year, grouping the album's tracks together, but with the yearly albums sorted randomly.  
 
  
+
::<span style="font-family: Consolas, monospace;">[Media Type]=[audio] ~limit=-1,1,[album] ~limit=-1,1,[year] ~a ~seq ~sort=Random ~limit=-1,3,[album],[album artist (auto)] ~sort=[Sequence]
 +
</span>
  
Note: The length field is calculated in seconds. The lastplayed field is calculated in minutes: <20 means smaller than, or within the last 20 minutes, whereas >20 means greater than, thus before the last 20 minutes. Using 10-30 means between 10 and 30 minutes.
+
[[Category:Frequently Asked Questions]]
 +
[[Category:Search]]
 +
[[Category:Developer]]

Revision as of 10:46, 6 May 2015

Media Center includes a rich and powerful query language which can be used to perform advanced searches. This system is the core of the Smartlist and Media Views systems in Media Center. This language is used to query the Library wherever you search for or filter files. Media Center provides a powerful wizard that can help you to build your search in an easy-to-understand and graphical manner. However, this graphical tool simply builds the search using the query language behind the scenes for you and then applies it. In all cases, you can instead write the query yourself using the full power of the Search Language if you need more flexibility than the graphical tool provides.

Searching

Before getting too detailed, it is essential to have a basic understanding of how a query works in Media Center. Being at its core a database, the Media Center library maintains information (or properties) for each file (e.g. audio tracks, image files, video files, etc.) that has been imported.

Conceptually, when performing a query, Media Center tests a search phrase against each file in the library. If the search phrase evaluates to true for the file, the file is included in the final file list; otherwise, it is not.

A search phrase may be one or more search terms. Each search term, in order, is tested against every file in the current file list. The basic idea is that of filtering. From the list of all imported files, a initial search term reduces the list, and additional search terms further narrows the results to produce a final list of matching files.

Queries can generally test any file properties, or even test the results from an evaluated expression. So long as the query produces a true value (a value of 1), the file will be included.

Queries are used or input in numerous places throughout Media Center - they are the heart of what drives file list production used to populate Views (panes and categories values, file lists) and Smartlists, or via Search to narrow the list of files presented in the current view. Queries can be entered in the Search bar using Text or Wizard mode, the Edit Smartlist dialog box, and in any Set rules for file display dialog available in view customization (Standard View, Theater View, Gizmo/WebGizmo, Media Network's DLNA server).

A simple query might test some value against the contents of a specific property, such as the name of an album, a date, or episode number. For example, the following search phrase:

[Album]=Pina

queries all files asking if the Album property contains the exact sequence of (case-insensitive) letters pina. Files that match are included in the resulting list; non-matching files are excluded.

Compound queries may be constructed by adding additional search terms, thus testing additional properties. Multiple search terms are combined by an implicit and operator. So it follows that the search phrase:

[Name]=Midnight [Artist]=Thelonious

queries all files whose Name contains Midnight and from those, queries the current list to test that the Artist property contains Thelonious.

Generally, any library field may be used in a query; see the Media Center File Properties document for a list of the standard properties, and see Options > Library & Folders > Manage Library Fields for the complete list, including custom user fields.

Keep in mind that the order of the files returned from a query is generally undefined or random. Sorting is done by the view, or specifically by other query constructs such as Modifiers.

The next few sections describe the available operators available to construct search queries from simple to complex. Following that will be a description of search query Modifiers.

Comparison Operators

The query language provides the standard comparison operators of equal-to, less-than, less-than/equal-to, greater-than and greater-than/equal-to. These allow defining a search term to compare a specified value against a given field (also called property).

For fields of type Date, values may include units such as d, w, y, h, m and s to indicate day, week, month, year, hour, minute, and second respectively. Floating point values may be used (e.g. .5w for 1/2 week).

When comparing the values of 0 and empty, it is important to understand how Media Center both stores and displays these values for the numeric and string datatypes. A 0 value for numeric types will be displayed in Media Center as empty, whereas for string types, as a 0. When comparing against numeric values, both 0 and empty [] are considered equivalent and either may be used. For string types, the 0 and empty values are distinct.

Note: For numeric types, the value of 0 is stored as a 0 internally, but Media Center uses a formatted display version of the field and shows it as an empty value. For example, if the field [My Integer Field] is set with the value of 0, it will show in a pane column or cell as empty. To see the actual value stored, use an expression column with the raw format field specifier ,0 in the field name just before the closing bracket: [My Integer Field,0]. Media Center typically uses the formatted version of the field, which is expressed as [My Integer Field,1], where the ,1 is the optional default.

Operator Description
field=value Equal to the specified value.

Example: Return all files whose Artist field contains smith anywhere.

[Artist]=Smith

field=<value Less than the specified value.

Example: Return all files imported within the last 1/2 day (12 hours):

[Date Imported]=<.5d

field=<=value Less than or equal to the specified value.

Example: Return all files that are rated less than or equal to 2:

[Rating]=<=2

field=>value Greater than the specified value.

Example: Return all files that are rated greater than 3:

[Rating]=>3

field=>=value Greater than or equal to the specified value.

Example: Return all files whose bitrate is greater than or equal to 256kbps:

[Bitrate]=>=256

Take note that the = character always follows a field name in comparison operations. In the case of equal to, the equivalence operator is implicit. This can be best illustrated by comparing the following example comparisons operations on the [Date (year)] field:

[Date (year)]=1980
[Date (year)]=<1980
[Date (year)]=<=1980
[Date (year)]=>1980
[Date (year)]=>=1980

Quoting and Anchoring

Certain characters are used by the Media Center query language (e.g. <space> as the separator for search terms). To use these characters, they need to be quoted. Additionally, by default, Media Center queries are free to search anywhere within a given property. The special constructs listed below provide a means to both quote and anchor search terms.

A pair of double quotes " " is used to include spaces or special characters in a search phrase. Replacing the opening quote with an opening bracket [ will anchor the search to the beginning. Likewise, the closing quote may be replaced with a closing bracket ] to anchor at the end. Replacing both quotes will fully anchor the search, requiring a full match from beginning to end. To search for an empty value, use the beginning and end anchored [] construct.

Quote/Anchor Description
"phrase" Double quotes are used to include spaces or special characters in the search phrase. The phrase will match anywhere within a string.

Example: Match something that contains the string Steve Miller:

"Steve Miller"

[phrase" Same as double quotes above, but forces the phrase to match only at the beginning of the string.

Example: Match something that starts with Stan, such as Stan Getz, Stand by Me, but not One Standard Night:

[Stan"

"phrase] Same as double quotes above, but forces the phrase to match only at the end of the string.

Example: Match something that ends with stand, such as I Will Stand, I Didn't Understand, but not The Standards:

"stand]

[phrase] Same as double quotes above, but forces the phrase to match both at the beginning and end of the string.

Example: Match exactly Bob Dylan and exclude Bob Dylan & the Band:

[Bob Dylan]

Example: Match empty values by forcing a match at the beginning and then immediately at the end:

[]

^word Restricts matching to a full word. A word is broken by space, punctuation, etc.

Example: Match car as a full word, as in A Car for All, but not Barcarolle.

^car

Grouping and Combining

Multiple search terms can be combined to form more complex queries. Queries are read and evaluated left to right. The and and or operations below are mathematical, and should not be interpreted as common language. A query of A and B means that A must be True and at the same time B must be True (common language interpretation could mean one desires items where A is True and also items where B is True, but this would be an or operation).

Grouping Description
s1 and s2 Narrows the results returned by requiring matches of both of the search terms s1 and s2.

Example: Return all files by artist Frank Sinatra and orchestra Tommy Dorsey:

[Artist]="Frank Sinatra" and [Orchestra]="Tommy Dorsey"

Since the and operation is implicit between search terms, is it not required. The following search phrase is equivalent to that shown in the example above:

[Artist]="Frank Sinatra" [Orchestra]="Tommy Dorsey"

s1 or s2 Expands the results returned by accepting matches of either (or both) of the search terms s1 or s2.

Example: Return all files named Spying Glass or named Angel:

[Name]=[Spying Glass] or [Name]=[Angel]

(s1 or s2) Groups search terms to force precedence when using multiple search terms with the and and the or operators.

Example: Return all files whose artist is exactly Bob Dylan and whose year is either 1966 or 2001:

[Artist]=[Bob Dylan] ([Date (year)]=1966 or [Date (year)]=2001)

Note the distinction of the example above with the following example:

[Artist]=[Bob Dylan] [Date (year)]=1966 or [Date (year)]=2001

The first example uses grouping parenthesis to force the order of evaluation, and returns files from Bob Dylan as the artist, from the year 1966 or 2001. The second example, due to order of evaluation from left to right, returns files with Bob Dylan as the artist from the year 1966, and also returns all files with year 2001.

val1,val2 Combines two or more values into a list, identical to the or operator. No spaces are allowed between the comma(s) and the values.

Example: Return all files whose artist is any of Queen, Heart, or the Grateful Dead:

artist=[Queen],[Heart],"Grateful Dead"

The search phrase in the example above is identical to the more cumbersome:

([Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead")

Negation and All

Operator Description
-field Inverts the sense of the comparison, returning those files whose field does not match the specified value. Usage is limited to the equality and comparison operators.

Example: Return all files whose track number is not 1:

-[Track #]=1

Example: Return all files whose track number is not greater than or equal to 3:

-[Track #]=>=3

Note that this equivalent to the more direct search phrase:

[Track #]=<3

Example: Return all files by artist Mark Isham, except those whose album names begin with after or quiz, or end with home, and exclude files from 1993:

[Artist]="Mark Isham" -[Album]=[after",[quiz","home] -[Date (year)]=1993

Example: Return all files that have associated artwork (i.e. [Image File] is not empty).

-[Image File]=[]

+field Forces matching all of the specified terms (useful for matching against list types). Usage is limited to the equality operator.

Example: Return all files with keywords Smith and Jones:

+[keywords]=[Smith],[Jones]

Example: Return all files with both of the artists Alison Krauss and Robert Plant:

+[Artist]=[Alison Krauss],[Robert Plant]

Modifiers

Queries and results can be modified by using one or more of the following special modifiers. Some modifiers act globally on, or affect the context of, the query, while others operate on the results returned as the query is being processed from left-to-right.

Some complex queries with modifiers will require manual entry in the Search Rules Importer/Exporter dialog available via the Import/Export button. The Edit Search wizard forces modifiers to the end of the query, thus removing the left-to-right processing required for certain modifiers such as ~seq or ~sort. Hint: always copy your complex query before leaving the Importer/Exporter so that it can be pasted again after testing.

Some of the modifiers below can operate on one or more fields. These compound field lists are expressed as a list of comma-separated fields [field1],[field2],...,[fieldn].

Note: For single character modifiers (i.e. ~n, ~d, ~s and ~t), the = character between the modifier and the value is optional (e.g., ~n30 is equivalent to ~n=30).

Modifier Description
~d=database Selects (limits) the Media Center database used in the query (e.g. Main, CD, Bad, Removed, etc.). More than one database may be specified by combining selectors.
Database selectors
a = All
b = Bad (or corrupt files get placed here) [starting w/v16.0.164]
c = CD (and DVDs)
e = Explorer
g = Guide (Television) [starting w/v15.0.160]
i = Category Images
m = Main
r = Removed [starting w/v15.0.160]
s = Store
t = Temporary (Playing Now)

Example: Limit the query to the CD and Main databases:

~d=cm

~dup=fields Returns a list of only duplicate files, where duplicates are determined by comparing the combined values in the specified fields list. Duplicate detection is based on matching values in fields, not by examining file content.

Example: Return a list of duplicate files by using the [Name] and [Artist] fields as the duplicate detectors:

~dup=[Name],[Artist]

~nodup=fields Returns a list with duplicate files removed, where duplicates are determined by comparing the combined values in the specified fields list. Only one of any duplicate file is included in the list. Duplicate detection is based on matching values in fields, not by examining file content.

Example: Return a list of all files with duplicates removed, by using the [Genre] field as the duplicate detectors. The returned list include one random file from each genre.

~nodup=[Genre]

~fill Returns a list of files to fill the specified device to maximum capacity. This modifier limits the number of files returned based on the amount of empty space left on the default or specified device.

Examples: Fill the default or specified device to maximum capacity:

~fill

~fill=[D:\]

~a Expands the track list (if necessary) to include the remaining tracks from the album(s).

Example: Return all tracks containing the name Feliz Navidad, and expand that list to include the remaining tracks in the album(s). If the track is on three albums, then all tracks from all three albums are returned.

[Name]="Feliz Navidad" ~a

~limit f,n,fields

Limits the set of files to at most n files from each of at most f values from the combined fields. This is easier explained with a simple example. From there, the general concept should be clearer.

Example: Limit the returned files, first by selecting at most 10 unique artists, and from each of those artists, return at most 2 files:

~limit=10,2,[Artist]

First 10 distinct artists will be randomly selected from the list of all possible artists, and then 2 random files from each of those artists will be selected and returned. If the limit cannot be satisfied (because there are too few artists, or too few files-per-artist), the available artists or files will be returned. In other words, these values are upper limits.

The value of -1 is used to select all values, and can be used for either f or n.

Example: Return all files from the Rock genre, but limit those results, first by randomly selecting at most 5 unique album / year pairs, and selecting all files from each of those albums:

[Genre]=Rock ~limit=5,-1,[Album],[Date (year)]

~n=num Limits to a maximum of num files.

Example: Return at most 20 randomly selected tracks:

~n=20

~mix=n,s Creates a mix of n files, according to the rules set by one or more comma-separated mix specifiers s. The format of each search specifier s is:

val,{criteria}

and val is either a number (e.g. 15) or a percentage (e.g. 10%), and criteria is a standard search phrase. The overall mix syntax follows the form:

~mix=n,val1,{criteria1},val2,{criteria2},...

The values val1, val2, ... should be either all percentages or all numeric, and should sum to either 100% or to the maximum number of tracks, respectively. Otherwise, the resulting mix proportions are not clearly defined.

Example: Selecting from all Rock tracks, return a 10-track mixture with a 60/40 percentage split between artists whose names contain Mark or Tom, respectively.

[Genre]=Rock ~mix=10,60%,{[Artist]=Mark},40%,{[Artist]=Tom}

~s=num Limits the number of files such that the cumulative size does not exceed num megabytes.

Example: Return a random set of files totaling a maximum of 650MB.

~s=650

~sort=fields Sorts the list of files by the specified list of fields.

Example: Sort the list of files first by date, and then by track number:

~sort=[Date],[Track #]

Sorting is in ascending order by default. Add -d to the end of a field to force descending sort order for that field.

Example: Sort the list of files first by date imported in reverse order, and then by album:

~sort=[Date Imported]-d,[Album]

Two special sort terms can be used: Random is used to randomize the order of list of files, and [Sequence] can be used to sort by the sequence number previously set with the ~seq modifier.

Example: Randomize (shuffle) the list of files:

~sort=Random

~t=num Limits the cumulative track time to not exceed the num minutes.

Example: Limit the set of files to a maximum of 60 minutes:

~t=60

~%=num Limits the set of files to a maximum of num percent of the total possible.

Example: Randomly select and return 50% of the files imported into Media Center within the last week:

[Date Imported]=<1w ~%=50

~seq Assigns a monotonically increasing sequence number to the current set of files. This modifier is useful in a more complex query to return the sort order set earlier.

Example: Select all tracks imported in the past 4 weeks, and sort them in descending order by date imported, assign a sequence number to be used later, limit the number of tracks to two per album, and sort based on the sequence number assigned earlier:

[Date Imported]=<4w ~sort=[Date Imported]-d ~seq ~limit=-1,2,[Album] ~sort=[Sequence]

~expand=fields Expands the included tracks on the given field.

Example: Expand the tracks to the matching genre:

~expand=Genre

Search, Search Wizard and More

The query language has grown over time, and there are several ways to express an identical query. Where Search tries to do what you mean (by searching most fields automatically and presenting a list of possible matches from which to choose), the translation into the Search Wizard often requires a more specific or precise query. Also note that the Search Wizard tends to restructure queries, preferring the less ambiguous, but more pedantic form. This can result in some queries not translating accurately from Search into Search Wizard. For example, the loosely written three-term search query using the or operator

[Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead"

will be incorrectly translated by Search Wizard into a three-term and operation

[Artist]=[Queen] [Artist]=[Heart] [Artist]="Grateful Dead"

instead of the correctly grouped search phrase

([Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead")

Media Center file properties support search keywords, often abbreviations or alternate forms of the property name. These keywords can be used to specify searching a given field. For example, the [Date (year)] field can be specified either by using its full field name [Date (year)] or by using the year= search keyword. As mentioned above, when pushing a query from Search into the Search Wizard, search keywords are translated into the field's full name form. This can be seen by entering a search keyword into Search, and then entering Search Wizard and using the Import/Export button to examine the full query.

Searching with Expressions

For richer, more advanced queries, Media Center Search supports using the Media Center Expression Language. Expression-based queries can be entered anywhere a Search query would be used, and as a Custom rule under Edit Search > Rules. The general syntax for using expressions formed as a query is:

[=expression]=value

Media Center will evaluate expression, and compare the result to value. All files for which the comparison produces a True result will be included in the query results. The following demonstrative (and utterly useless) queries would return all files:

[=1]=1
[=math(0 * 2)]=0

The equal comparison operator is a string comparison, so the following expression-based search works as expected:

[=Orientation()]=Portrait

Currently only the equal operator is supported. Be sure to properly quote value when necessary, as mentioned above in Quoting and Anchoring. In the following examples, the first search expression will be True for all files, and the second will be False:

[=math(10 + 1)]=1
[=math(10 + 1)]=[1]

Search and Locales

Certain characters such as period and comma are affected by the Windows locale settings. In some locales, a comma is used for the decimal point. Since Media Center reads input in the English locale and outputs values in the current locale, this can affect search results in unexpected ways. Consider the query below. It tests against the value of 1 or 2 and not the value of 1 point 2:

[My Decimal Field]=1,2

Be sure to format your queries using Media Centers expected input, and that any input or output from expression-based queries are formatted accordingly.

Current Limitations or Bugs

The following are some of the known limitations and/or bugs with certain queries:

1. The values used in the ~mix modifier val1, val2, ... should be either all percentages or all numeric, and should sum to either 100% or to the maximum number of tracks, respectively. Otherwise, the resulting mix proportions are not clearly defined.

2. Translations from Search Text to Search Wizard may cause changes in the meaning of the search query. The text entered as:

[Artist]=[Queen] or [Artist]=[Heart] or [Artist]="Grateful Dead"

becomes translated incorrectly by Search Wizard into:

[Artist]=[Queen] AND [Artist]=[Heart] AND [Artist]="Grateful Dead"

and

[Rating]=1,2

becomes

[Rating]=1; 2

which then finally becomes

[Rating]=1 2

Examples

The following are a few example queries to help solidify your understanding of how to form search queries. These rules can be copy/pasted into the Search box, and you can use the Search Wizard for more assistance in developing search rules. Note: some of the examples show variations of the same rule, illustrating the use of full field names or their (keyword) abbreviations.

Example: Files from album names containing Greatest Hits:

[album]="Greatest Hits"
al="Greatest Hits"

Example: Files imported into Media Center in the past 7 days:

[Date Imported]=<=7d
dateimported=<=7d

Example: Tracks greater than 5 minutes (300 seconds) in duration (length) that have played in the last 60 minutes, with the results sorted by track length:

Duration]=>300 [Last Played]=<60m ~sort=[Duration]
length=>300 lastplayed=<60m ~sort=length

Example: All mp3 files by any artist whose name begins with Joe:

[File Type]=mp3 [Artist]=[Joe"

Example: Files that are in either the genre Opera or Classical:

[Genre]=[Opera] or [Genre]=[Classical]
g=[Opera] or g=[Classical]
g=[Opera],[Classical]

Example: Files from genre names beginning with Rock, where the number of plays is less than 5, and the Artist is neither Sting nor Beatles, shuffling the results:

[Genre]=[Rock" [Number Plays]=<5 -[Artist]=Sting,Beatles ~sort=Random

Example: Ten random files from the "Top 40 1983" playlist which were not played in the last 5 days:

[Playlist]="Top 40 1983" [Last Played]=>5d ~n=10

Example: 60 minutes worth of files rated 3 or higher, sorted randomly:

~sort=Random [Rating]=>=3 ~t=60

Example: 100 rock tracks, 50% of which are rated 4 and 5, 25% of which are rated 1 and 2 and 25% unrated:

g=rock ~mix=100,50%,{[Rating]=>3},25%,{[Rating]=1,2},25%,{[Rating]=[]}

Example: 50 tracks, ½ of which are Country Rock, and ½ of which are Alternative Rock:

~mix=50,50%,{[Genre]=[Country Rock]},50%,{[Genre]=[Alternative Rock]}

Example: From the opera genre, limit the results to all tracks from seven albums:

[genre]=[opera] ~limit=7,-1,[album]

Example: One file from each artist, and from those only two files per year:

~limit=-1,1,[Artist] ~limit=-1,2,[Year]

Example: Images from the years 1930 to 1963, limited to 1 random year with the results randomly sorted:

[Media Type]=[Image] [Date (year)]=1930-1963 ~limit=1,-1,[Year] ~sort=Random

Example: Files with a rating of 4 and that are either in the rock genre or from the year 1970 to 1980 (compare with the next example):

[Rating]=4 ([Genre]=[Rock] or [Date (year)]=1970-1980)

Example: Files with a rating of 4 and in the rock genre, or files from the year 1970 to 1980 (compare with the previous example):

[Rating]=4 [Genre]=[Rock] or [Date (year)]=1970-1980

Example: Randomly select 3 songs from one album per year, grouping the album's tracks together, but with the yearly albums sorted randomly.

[Media Type]=[audio] ~limit=-1,1,[album] ~limit=-1,1,[year] ~a ~seq ~sort=Random ~limit=-1,3,[album],[album artist (auto)] ~sort=[Sequence]