[Nepomuk] Help to understand how to build a query
daitheflu at free.fr
Thu Sep 22 09:13:46 UTC 2011
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,
More information about the Nepomuk