Hi guys, Thank you once more for your help. I'm putting your names right now on the list of people to whom I owe at least one beer.
I think I've done something very similar to what Sebastian wrote. Does the order of "filters" matters when building the query ? For example : does 1. addIncludeFolder and 2. Set the Terms gives the same results as 1. Set the Terms and 2. addIncludeFolder ? If not, I'll try to see if my file indexer is working properly. Thanks again :) -- François ----- "Sebastian Trüg" <[email protected]> a écrit : > De: "Sebastian Trüg" <[email protected]> > À: "Vishesh Handa" <[email protected]> > Cc: [email protected] > Envoyé: Jeudi 22 Septembre 2011 14h28:03 GMT +01:00 Amsterdam / Berlin / > Berne / Rome / Stockholm / Vienne > Objet: Re: [Nepomuk] Help to understand how to build a query > > On 09/22/2011 02:24 PM, Vishesh Handa wrote: > > > > > > On Thu, Sep 22, 2011 at 5:42 PM, Sebastian Trüg <[email protected] > > <mailto:[email protected]>> wrote: > > > > Hi Francois, > > > > Here is the C++ code which would do it: > > > > OrTerm mimeTypeTerm; > > foreach(QString mimeType, mimeTypes) > > mimeTypeTerm.addSubTerm(ComparisonTerm(NIE::mimeType(), > mimeType, > > ComparisonTerm::Equal); > > > > FileQuery query(AndTerm(mimeTypeTerm, > ResourceTypeTerm(NFO::Video()); > > foreach(QString folder, myFolders) > > query.addIncludeFolder(folder); > > > > > > You could also do a - > > > > FileQuery query( mimeTypeTerm && ResourceTypeTerm(NFO::Video()) ); > > Not in Python. :) > > > > > > > That's it. If you want you can remove the ResourceTypeTerm just > for > > testing. > > If this query does not work maybe your file indexer is > disabled? > > > > Cheers, > > Sebastian > > > > On 09/22/2011 11:13 AM, François K. wrote: > > > Hi ! > > > > > > I'm trying to understand how to build a simple query, using > the > > query API. > > > My goal is pretty simple : I want to list all video files > stored > > in some given directories that Phonon can play. > > > > > > I tried several "things" without success which leads me to > the > > asumption that I might have misunderstood something, hence my > call > > for help :) > > > > > > This is what I did in my last try : > > > > > > STEP 1 : > > > * Create a new Nepomuk.Query.FileQuery > > > * Ask to look for files only via > > setFileMode(Nepomuk.Query.FileQuery.QueryFiles) > > > * Loop through my 'sources' and add them as sources via > > addIncludeFolder(source, True) > > > > > > STEP 2 : > > > * Create a ResourceTypeTerm to get only Video files > (NFO::Video()) > > > > > > STEP 3 : > > > * Get the list of video mimetypes that Phonon can play. > > > * Loop through this list, and build a ComparisonTerm for each > > playable mimetype : > > > - The ComparisonTerm is made of the mimetype Property > > (NIE::mimeType()) and a LiteralTerm containing the current > mimetype. > > > * Add all these ComparisonTerms in a OrTerm. > > > > > > STEP 4 : > > > * Build a new AndTerm. > > > * Add the ResourceTypeTerm built in STEP 2 to it. > > > * Add the OrTerm built in STEP 3 to it. > > > > > > STEP 5 : > > > * Add the AndTerm built in STEP 4 to my Query. > > > * Run the query : zero result :( (and there are some). > > > > > > > > > I can provide (Python) code if you want. > > > > > > What am I missing/doing wrong ? I really need to understand > the > > logic behind the query system since I'm looking forward to use > > Nepomuk almost everywhere in my app. > > > So my question isn't really about that precise case, but > rather > > "how do you guys build your query ?" > > > > > > > > > Oh, also, my strigi didn't index those files yet because of > > crashes (but nepomuk is running). Does it matter ? > > > > > > > > > Thanks a lot, > > > > > _______________________________________________ > > Nepomuk mailing list > > [email protected] <mailto:[email protected]> > > https://mail.kde.org/mailman/listinfo/nepomuk > > > > > > > > > > -- > > Vishesh Handa > _______________________________________________ > Nepomuk mailing list > [email protected] > https://mail.kde.org/mailman/listinfo/nepomuk _______________________________________________ Nepomuk mailing list [email protected] https://mail.kde.org/mailman/listinfo/nepomuk
