haiku/docs/welcome/queries.html

119 lines
6.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Queries</title>
<link rel="stylesheet" type="text/css" href="welcome.css">
</head>
<body lang="en-US">
<div class="logo">
<img src="welcome-images/logo.png" alt="logo">
<div class="title">Queries</div>
</div>
<div class="topnav">
<p>
<a href="welcome.html">Welcome</a>
&nbsp;&nbsp;&nbsp;
Previous: <a href="index.html">The Index</a>
</p>
</div>
<div class="content">
<h2>Queries</h2>
<p>A query is a file search based on file attributes and can be performed within Tracker or in Terminal. Queries are saved in "<tt>/boot/home/queries</tt>" and by default last seven days before being purged. Note, that these aren't static result lists of your search, but are the query formulas which trigger a new search whenever you open them.
</p>
<h3>The Find window</h3>
<p>You start a query by invoking the <i>Find...</i> menu either from the Deskbar menu or any Tracker window or the Desktop (which is actually a fullscreen Tracker window). The shortcut is <tt>ALT+F</tt>. You're presented with the Find window:
<br>
<br>
<img src="queries-images/basic-query.png" alt="basic-query.png" width="517" height="292">
<br>
</p><p>[1] Select previous or saved queries or save the current query.<br />
[2] Narrow down your search from "All files and folders" to specific file
types.<br />
[3] Define the search method:<ul>
<li><i>by Name</i> - a basic search by filename</li>
<li><i>by Attribute</i> - an advanced search, you specify search terms for one or more attributes</li>
<li><i>by Formula</i> - an even more advanced search, you can fine-tune a complex query term</li></ul>
[4] Select which drives to search on.<br />
[5] Enter the search term.<br />
[6] The expander hides/unhides the additional options.<br />
[7] Uncheck the <i> Temporary</i> checkbox if you don't want this query self-destruct after 7 days.<br />
[8] Check if your query is supposed to <i>Include trash</i>.<br />
[9] Optionally, enter a name for this query if you want to save it.<br />
[10] You can drag&amp;drop the icon to save the query.
</p>
<h3>Basic queries - "by Name"</h3>
<p>If you simply want to find all files on your mounted disks that match a certain pattern, simply leave the search method at "<i>by Name</i>", enter the search term into the text box and press <tt>ENTER</tt>.
</p>
<h3>Advanced queries - "by Attribute"</h3>
<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 indexed (see <a href="index.html">Index</a>).
<br>
<br>
<img src="queries-images/query-window.png" alt="query-window.png" width="441" height="172">
<br>
</p><p>You start by setting the filetype from "<i>All files and folders</i>" to "<i>text | E-mail</i>" and change the search method to "<i>by Attribute</i>.
</p><p>This adds a dropdown menu to the left of the textbox and the buttons "<i>Add</i> and <i>Remove</i> under that. From the menu you choose which attribute to query. With "<i>Add</i> and <i>Remove</i> you can query additional attributes or remove them again. These attributes can be logically linked with AND/OR.
</p><p>Let's do an email query as an example:
<br>
<br>
<img src="queries-images/query-window-filled.png" alt="query-winsow-filled.png" width="441" height="262"<br>
</p><p>This is your Find window when you're looking for all emails Clara Botter has sent to you in the last two months that had in the subject "vibraphone" or "skepticality".
</p>
<h3>Even more advanced queries - "by Formula"</h3>
<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
"<i>by Formula</i> mode and be overwhelmed by this one line query string:
<br>
<img src="queries-images/formula-query.png" alt="formula-query.png" width="441" height="173">
<br>
</p><p>Once more as text, edited for readability:
</p>
<pre>(((((MAIL:from==&quot;*[cC][lL][aA][rR][aA] [bB][oO][tT][tT][eE][rR][sS]*&quot;)
&amp;&amp;(MAIL:when&gt;=%2 months%))
&amp;&amp;(MAIL:subject==&quot;*[vV][iI][bB][rR][aA][pP][hH][oO][nN][eE]*&quot;))
||(MAIL:subject==&quot;*[sS][kK][eE][pP][tT][iI][cC][aA][lL][iI][tT][yY]*&quot;))
&amp;&amp;(BEOS:TYPE==&quot;text/x-email&quot;))</pre>
<p>What's the use?</p>
<ul>
<li>You could copy and paste the string into an email, forum or IRC for others to use or debug.</li>
<li>You can use this method to construct a query in "<i>Attribute</i> mode and then switch to "<i>Formula</i> mode, to comfortably generate a search string to use for a query in Terminal or a script.</li>
<li>You can fine tune your query by inserting paranthesis 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 <a href="http://en.wikipedia.org/wiki/Regular_expression" class='external free' title="http://en.wikipedia.org/wiki/Regular expression" rel="nofollow">regular expressions</a> and maybe some scripting basics.</li>
</ul>
<h3>The result window</h3>
<p>After you start a search, the Find window will be replaced by a result window. Here is an example that queried for "server":
</p><p><img src="queries-images/result-window.png" alt="result-window.png" width="704" height="359">
</p><p>Besides the grey backgound, result windows work exactly like any other Tracker window. Some things are worth noting:
</p>
<ul>
<li>You can open the folder a file resides in by double clicking on its path attribute.</li>
<li>With <i>File | Edit Query</i> or <tt>ALT+G</tt> you get back to your Find window to refine your query.</li>
<li>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 resuls in
realtime.
</ul>
<p>You can assign a sensible attribute layout for query results of a specific filetype. Open the 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 <i>Attributes | Copy Attributes</i>.
</p><p>Open <tt>/boot/home/config/settings/Tracker/DefaultQueryTemplates</tt>, create a new folder and rename it to <i>group/filetype</i>, replacing slashes with underscores, e.g."audio_x-mp3".
Open the new folder and paste in the layout with <i>Attributes | Paste Attributes</i>.
</p>
</div>
<div class="bottomnav">
<p>
<a href="welcome.html">Welcome</a>
&nbsp;&nbsp;&nbsp;
Previous: <a href="index.html">The Index</a>
</p>
</div>
</body>
</html>