2007/9/17, Anders Rune Jensen &lt;<a href="mailto:anders@iola.dk">anders@iola.dk</a>&gt;:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 9/17/07, Mikkel Kamstrup Erlandsen &lt;<a href="mailto:mikkel.kamstrup@gmail.com">mikkel.kamstrup@gmail.com</a>&gt; wrote:<br>&gt; 2007/9/17, Mikkel Kamstrup Erlandsen &lt;<a href="mailto:mikkel.kamstrup@gmail.com">mikkel.kamstrup@gmail.com
</a>&gt;:<br>&gt; &gt; 2007/9/17, Anders Rune Jensen &lt;<a href="mailto:anders@iola.dk">anders@iola.dk</a>&gt;:<br>&gt; &gt;<br>&gt; &gt; &gt; Hi<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; I&#39;ve been reading the Xesam Query Language specification and I have a
<br>&gt; questions:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; 1) How do I get all tags for all files? Preferable as list&lt;name,<br>&gt; &gt; &gt; count&gt;. The same is true for other attributes such as mime-types.<br>&gt; &gt;
<br>&gt; &gt;<br>&gt; &gt; You are right that there is no obvious way to do this atm. I think the<br>&gt; best solution is to simply add a new selector called &quot;any&quot;, and use it like<br>&gt; the following.<br>&gt; &gt;
<br>&gt; &gt; Firstly note that the ontology does not yet implement Tags as first class<br>&gt; objects, but this is on Evgenys todo I believe. Since this is not ready yet<br>&gt; consider the following an example only.<br>
&gt; &gt;<br>&gt; &gt; Assume that the Tag objects has a field xesam:tagName. The return type for<br>&gt; GetHits is controlled via the session property hit.fields, so if&nbsp;&nbsp;you set<br>&gt; this to [xesam:tagName] and do the query
<br>&gt; &gt;<br>&gt; &gt; &lt;request xmlns=&quot;<br>&gt; <a href="http://freedesktop.org/standards/xesam/1.0/query">http://freedesktop.org/standards/xesam/1.0/query</a>&quot;&gt;<br>&gt; &gt;&nbsp;&nbsp; &lt;query content=&quot;xesam:Tag&quot;&gt;
<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;any/&gt;<br>&gt; &gt;&nbsp;&nbsp; &lt;/query&gt;<br>&gt; &gt; &lt;/request&gt;<br>&gt; &gt;<br>&gt; &gt; GetHits will give you all all known Tag names. If you want the count for<br>&gt; each tag I see two solutions. Either the ontology should define a field
<br>&gt; xesam:memberCount or something like that, or you create a new search for<br>&gt; each tag like<br>&gt; &gt;<br>&gt; &gt; &lt;request<br>&gt; xmlns=&quot;<a href="http://freedesktop.org/standards/xesam/1.0/query">
http://freedesktop.org/standards/xesam/1.0/query</a>&quot;&gt;<br>&gt; &gt;&nbsp;&nbsp; &lt;query content=&quot;xesam:Tag&quot;&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;equals&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=&quot;xesam:tagName&quot;/&gt;<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;string&gt;TAGNAME_HERE&lt;/string&gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/equals&gt;<br>&gt; &gt;&nbsp;&nbsp; &lt;/query&gt;<br>&gt; &gt; &lt;/request&gt;<br>&gt; &gt;<br>&gt; &gt; and simply issue GetHitCount on each search and then close it. This should
<br>&gt; actually be fairly efficient on most backends.<br>&gt; &gt;<br>&gt; &gt; It should be noted that tagging and tag management as such might be hard<br>&gt; to implement completely in the search API. The search API is mainly
<br>&gt; targetted at &quot;search&quot; :-) In XESAM iteration 2 we will focus on a metadata<br>&gt; management API where such things might be more natural.<br>&gt;<br>&gt; I just realised that my answer above does not answer your question about
<br>&gt; mime types and other similar things you might want to list.<br>&gt;<br>&gt; I think what you ask for is a way to request all different values for a<br>&gt; given field. I&#39;m not 100% sure that all implementations can support this
<br>&gt; effectively. Lucene does not support this AFAIK.<br>&gt;<br>&gt; Another thing is the use case... In the case of mime types why can&#39;t you use<br>&gt; the conventional ways to get a list of known mime types? Why would you
<br>&gt; generally want to list all known values of a field? I&#39;m thinking some<br>&gt; clustered browsing or something...<br><br>The use case would be something like a music program where you would<br>like to know what audio types is stored on the hd (mp3, ogg, flac
<br>etc.) and then add only those as buttons so the user can for example<br>select only flac files. Also it could be nice to know how many flac<br>files there where before clicking the flac button. In particular<br>because the result list might be limited to a certain number of
<br>results (and because getting the total number (just the count) of flac<br>files this way is inefficient ;-)).</blockquote><div><br>In this case I think it is perfectly OK to spawn a search for each supported audio mime type and  issue only a GetHitCount call on each search before you close it (if we are talking &lt; 10 or so). That should be quite fast on all backends since there is no real data transmission going on. Moreover if the hit data is only fetched lazily (like Lucene (and Xapian I believe)) then the overhead of requesting a few hit counts is really small. I don&#39;t know how fast Tracker would be here, but I suspect plenty fast.
<br></div><br></div>Cheers,<br>Mikkel<br>