Hi!<br><br><div class="gmail_quote">On Wed, Mar 2, 2011 at 10:00 AM, Sebastian Trüg <span dir="ltr">&lt;<a href="mailto:trueg@kde.org" target="_blank">trueg@kde.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Good to know.<br></blockquote><div><br></div><div>Yes, sure :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For now simply put the query term in a single LiteralTerm:<br>
<br>
LiteralTerm(&quot;hello world this is several terms&quot;)<br>
<br>
That will do it.<br>
<br>
Your problem is that what you wrote with the query API is not what you<br>
meant.<br>
<br>
AndTerm( LiteralTerm(&quot;A&quot;), LiteralTerm(&quot;B&quot;) )<br>
<br>
will look for all resources that have term &quot;A&quot; in any property value and<br>
term &quot;B&quot; in any property value. What you want (and do in your query) is<br>
looking for all resources that have a properly value that contains &quot;A&quot;<br>
and &quot;B&quot;. See the difference? Using 6 LiteralTerms gets you a really big<br>
join.<br></blockquote><div><br></div><div>No, I precisely I&#39;m trying that you mean. I look for all resources that have term &quot;A&quot; in any property, etc... as my query does in a limited manner. I have several asian names in my db &quot;ha ji won&quot;, &quot;kim sa rang&quot;, &#39;lee dae hae&quot;, &quot;uhm ji won&quot;, etc... and even this Asian names could be writen in several manners: Yūko, Yuuko, Yuko, ゆうこ, 裕子, etc... so I could need this kind of queries.</div>


<div><br></div><div>I will work this night your queries because I think that can be improved.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Sebastian<br>
<div><div></div><div><br>
On 03/01/2011 11:05 PM, Ignacio Serantes wrote:<br>
&gt; Hi!<br>
&gt;<br>
&gt; As Sebastian suggested I tried the search API without my dirty hack and<br>
&gt; I finally learn how to use it. This is my first successful code:<br>
&gt;<br>
&gt;     term =<br>
&gt;     Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;música&quot;,<br>
&gt;     &#39;UTF-8&#39;)))<br>
&gt;     query = Nepomuk.Query.Query(term)<br>
&gt;     [code #1]<br>
&gt;     query.addRequestProperty(Nepomuk.Query.Query.RequestProperty(Nepomuk.Types.Property(NEO(&#39;nie#url&#39;,<br>
&gt;     True))))<br>
&gt;     query.addRequestProperty(Nepomuk.Query.Query.RequestProperty(Nepomuk.Types.Property(NEO(&#39;nao#prefLabel&#39;,<br>
&gt;     True))))<br>
&gt;     sparqlQuery = query.toSparqlQuery()<br>
&gt;     model = Nepomuk.ResourceManager.instance().mainModel()<br>
&gt;     data = model.executeQuery(sparqlQuery,<br>
&gt;     Soprano.Query.QueryLanguageSparql)<br>
&gt;     ... &lt; code to display result set &gt; ...<br>
&gt;     [code #1]<br>
&gt;<br>
&gt;<br>
&gt; The query is slow but works and columns url and prefLabel are available.<br>
&gt; Great!<br>
&gt; 896 results found in 7.69615888596 seconds<br>
&gt;<br>
&gt; I have a common query I used often when I&#39;m developing &quot;ha ji won kim sa<br>
&gt; rang&quot; because result set has one row (this is equivalent to write &quot;&#39;ha&#39;<br>
&gt; and &#39;ji&#39; and &#39;won&#39; and &#39;kim&#39; and &#39;sa&#39; and &#39;rang&#39;) and this is the result<br>
&gt; set with a query generated by my builder nsSparqlBuilder.<br>
&gt;<br>
&gt; file:///media/HD1.5TB-01/video/corea/doramas/Secret Garden, [FileDataObject]<br>
&gt; 1 results found in 1.21383500099 seconds.<br>
&gt;<br>
&gt; So I wrote the next code to test the API expecting same results:<br>
&gt;<br>
&gt;     andTerm = Nepomuk.Query.AndTerm()<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ha&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ji&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;won&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;kim&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;sa&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;rang&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     query = Nepomuk.Query.Query(andTerm)<br>
&gt;     [code #1]<br>
&gt;<br>
&gt; and this is the result set I obtained:<br>
&gt;<br>
&gt; (iODBC Error: [OpenLink][Virtuoso iODBC Driver][Virtuoso Server]SQ200:<br>
&gt; The memory pool size 400005656 reached the limit 400000000 bytes, try to<br>
&gt; increase the MaxMemPoolSize ini setting)&quot;<br>
&gt; 0 results found in 85.3466908932 seconds<br>
&gt;<br>
&gt; Them I deleted two terms, the second and the five and there is no error<br>
&gt; but result set is the next one:<br>
&gt; 0 results found in 600.101149082 seconds<br>
&gt;<br>
&gt; Finally I discover that generated API queries works with two terms and<br>
&gt; fails with more. For example, the next test is very slow but works:<br>
&gt;<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ha&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ji&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;<br>
&gt;<br>
&gt; nepomuk:/res/c894d8fa-cb6a-4ab3-ab26-37a6abbe206e, , ha ji won<br>
&gt; nepomuk:/res/c0642c10-6501-448c-a8ed-4992f45c232e,<br>
&gt; file:///media/HD1.5TB-01/video/corea/doramas/Secret Garden,<br>
&gt; 2 results found in 25.7656869888 seconds<br>
&gt;<br>
&gt; but the next one not:<br>
&gt;<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ha&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ji&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;     andTerm.addSubTerm(Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;won&quot;,<br>
&gt;     &#39;UTF-8&#39;))))<br>
&gt;<br>
&gt;<br>
&gt; and result is:<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; local socket error: QLocalSocket::SocketTimeoutError<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; 0 results found in 1201.46248913 seconds<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt; &quot;&quot; Soprano: &quot;Command timed out.&quot;<br>
&gt;<br>
&gt; In documentation there is no limit to the number of terms you can add<br>
&gt; and even there is a constructor where you can add 6 terms. I tried it<br>
&gt; but results are the same, the first term works but the second one not.<br>
&gt;<br>
&gt;         term = Nepomuk.Query.AndTerm( \<br>
&gt;             Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ha&quot;,<br>
&gt; &#39;UTF-8&#39;))), \<br>
&gt;             Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ji&quot;,<br>
&gt; &#39;UTF-8&#39;))), \<br>
&gt;<br>
&gt; Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;won&quot;, &#39;UTF-8&#39;))) \<br>
&gt;             )<br>
&gt;<br>
&gt;         term = Nepomuk.Query.AndTerm( \<br>
&gt;             Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;ha&quot;,<br>
&gt; &#39;UTF-8&#39;))), \<br>
&gt;<br>
&gt; Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(unicode(&quot;won&quot;, &#39;UTF-8&#39;))) \<br>
&gt;             )<br>
&gt;<br>
&gt; On the other side using API if external hard drive is not mounted result<br>
&gt; sets are empty. This behavior can be disabled?<br>
&gt;<br>
&gt; I only tried AndTerm but tomorrow I will try OrTerm if I have free time.<br>
&gt;<br>
&gt; --<br>
&gt; Cheers,<br>
&gt; Ignacio<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Nepomuk mailing list<br>
&gt; <a href="mailto:Nepomuk@kde.org" target="_blank">Nepomuk@kde.org</a><br>
&gt; <a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
_______________________________________________<br>
Nepomuk mailing list<br>
<a href="mailto:Nepomuk@kde.org" target="_blank">Nepomuk@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Cheers,<div>Ignacio</div><div><br></div><br>