<ahref="#more-adv-query">Even more advanced queries - "by Formula"</a><br/>
<ahref="#result-window">The result window</a><br/>
<ahref="#query-template">Query Templates</a>
</td></tr>
</table>
<h1>Queries</h1>
<p>A query is a file search based on file attributes and can be performed within Tracker or in Terminal. Queries are saved in <spanclass="path">/boot/home/queries/</span> and by default last seven days before being purged. Note, these aren't static result lists of your search, but are the query formulas which trigger a new search whenever you open them.<br/>
Even better, you don't have to double-click to re-do a query. You can <ahref="tracker.html#navigating">drill down</a> a saved query just like any folder by right-clicking on it and navigating through the submenus.</p>
<p>You start a query by invoking the <spanclass="menu">Find...</span> menu either from the Deskbar menu or any Tracker window or the Desktop (which is actually a fullscreen Tracker window). The shortcut is <spanclass="key">ALT</span><spanclass="key">F</span>. You're presented with the Find window:</p>
<li><p>Select recent or saved queries or save the current search parameters as <ahref="#query-template">Query Template</a>.</p></li>
<li><p>Narrow down your search from <spanclass="menu">All files and folders</span> to specific file types.</p></li>
<li>Define the search method:<ul>
<li><spanclass="menu">by Name</span> - a basic search by file or folder name</li>
<li><spanclass="menu">by Attribute</span> - an advanced search, you specify search terms for one or more attributes</li>
<li><spanclass="menu">by Formula</span> - an even more advanced search, you can fine-tune a complex query term</li></ul></li>
<li><p>Select which drives to search on.</p></li>
<li><p>Enter the search term.</p></li>
<li><p>The expander hides/unhides the additional options.</p></li>
<li><p>Uncheck the <spanclass="menu">Temporary</span> checkbox if you don't want this query self-destruct after 7 days.</p></li>
<li><p>Check if your query is supposed to <spanclass="menu">Include trash</span>.</p></li>
<li><p>Optionally, enter a name for this query if you want to save it.</p></li>
<li><p>You can drag&drop the icon anywhere to save a query. Doing that with the right mouse button, offers the option to save as template.</p></li>
<p>If you simply want to find all files and folders on your mounted disks that match a certain pattern, simply leave the search method at <spanclass="menu">by Name</span>, enter the search term into the text box and press <spanclass="key">ENTER</span>.</p>
<p>You can create more advanced queries by searching within the attributes of specific file types. For that to work, these attributes have to be <ahref="index.html">indexed</a>.</p>
<p>You start by setting the filetype from <spanclass="menu">All files and folders</span> to, for example, <spanclass="menu">Text | E-mail</span> and change the search method to <spanclass="menu">by Attribute</span>.</p>
<p>This adds a pop-up menu to the left of the textbox and the buttons <spanclass="button">Add</span> and <spanclass="button">Remove</span> under that. From the menu you choose which attribute to query. With <spanclass="button">Add</span> and <spanclass="button">Remove</span> you can query additional attributes or remove them again. These attributes can be logically linked with AND/OR.</p>
<p>This is your Find window when you're looking for all emails Clara Botters has sent to you in the last two months that had in the subject "vibraphone" or "skepticality".<br/>
As you see, searching through time-based attributes supports some useful phrases: besides for the "last 2 months", you could also use "today", "yesterday", "Monday" or "last Monday" (which would be the Monday last week), or "last 2 minutes/hours/days/weeks".<br/>
A good way to cut down the number of search results.</p>
<aid="more-adv-query"name="more-adv-query">Even more advanced queries - "by Formula"</a></h2>
<p>Typing in a formula query by hand is daunting and really quite unpractical. It still has its uses.</p>
<p>Take the above query by attribute of Clara's mails concerning vibraphones etc. If you have all the attributes and their search terms set, try switching to <spanclass="menu">by Formula</span> mode and be overwhelmed by this one line query string:</p>
<li><p>You could copy and paste the string into an email, forum or IRC for others to use or debug.</p></li>
<li><p>You can use this method to construct a query in <spanclass="menu">Attribute</span> mode and then switch to <spanclass="menu">Formula</span> mode, to comfortably generate a search string to use for a query in Terminal or a script.</p></li>
<li><p>You can fine tune your query by inserting parenthesis where needed, make parts case-sensitive or negate logical combinations by changing. e.g. "<tt>==</tt>" to "<tt>!=</tt>" for a NOT AND. All you need is a basic understanding of <ahref="http://en.wikipedia.org/wiki/Regular_expression"class="external free"title="Wikipedia: Regular expression">regular expressions</a> and maybe some scripting basics.</p></li>
<li><p>With <spanclass="menu">File | Edit query</span> or <spanclass="key">ALT</span><spanclass="key">G</span> you get back to your Find window to refine your query.</p></li>
<li><p>A query is live, i.e. if a file that matches your search criteria appears or disappears from your system, this change is reflected in your results in real-time.</p></li>
<p>You can assign a sensible attribute layout for query results of a specific filetype. Open a folder containing files of the filetype you'd like to create a template for and arrange the attributes how you'd like to have query results presented. Copy this layout with <spanclass="menu">Attributes | Copy layout</span>.</p>
<p>Open <spanclass="path">/boot/home/config/settings/Tracker/DefaultQueryTemplates</span>, create a new folder named <i>group/filetype</i>, replacing the slash with an underscore, e.g. "audio_x-mp3". Open the new folder and paste in the previously copied layout with <spanclass="menu">Attributes | Paste layout</span>.</p>
<p>If you double click a saved query, the file search is at once started and the result window opens immediately. However, you may not want to search with these <i>exact</i> search parameters, but use it as starting point to only slightly tweak the formula.<br/>
By using the <spanclass="menu">Save query as template</span> menu item (see <ahref="#find-window">(1) in screenshot</a> at the top) or drag&dropping the icon (10) anywhere with the right mouse button, you can create just such a template. Double clicking it won't open a result window, but the Find panel, giving you the opportunity to quickly change search strings or add/remove attributes.</p>