[Nepomuk] Current logic of query types - is it a bug or a feature

Vishesh Handa me at vhanda.in
Wed Jun 18 16:59:43 UTC 2014


On Tue, Jun 17, 2014 at 7:47 AM, Andrey Bondrov <andrey.bondrov at rosalab.ru>
wrote:

> Hi all.
>
> I'm trying to port SimpleWelcome application (a launcher for KDE used
> in ROSA Desktop by default) from Nepomuk to Baloo. And I have some
> questions about Baloo (unfortunately, the only useful documentation on
> Baloo seems to be its source code).
>

Yes. We're severely lacking documentation.


> 1. Current logic of query types - is it a bug or a feature? I mean it
> seems to use AND instead of OR, so nothing is found when I set multiple
> types for a query (unless it's "File/Something"). Is there a way to
> query types with OR?
>
>
Unfortunately, not with the API exposed.

The main reason this was done was because each type can be stored in a
separate database. Emails are stored in a completely separate place as is
the file index. Plus, I was at some point trying to store each major file
type in a different database (as a performance boost).

We could probably modify the API to support OR types after a main type.

So, Main Type: File
       Secondary Types: Image or Audio or Document


> 2. Is there complete list of terms used by Baloo ("modified" etc)?
>

Have a look at kfilemetadata/properties.

The modified property is actually not available. It is stored internally,
but its stored in a different way than all of the file properties. Would
QFileInfo(url).modified() do?


> 3. Is there a way to get sorted results from a query? For example, 10
> latest modified images.
>

Not in a very efficient way. We currently do this for emails, but since we
are an index or sorting abilities are much slower.

Anyway, I never landed up adding a sorting API, since it wasn't used.
Perhaps we could come up with one? There is a FIXME for sorting in the
query.h file. Currently, for emails we try out best to return the most
recently modified email first.

4. Is there a way to query images by size? And get image size from
> query results?
>

Yes, to both.

The API isn't the best, but it can still be improved.

Searching - You'll have to specify the exact width and height. Comparison
operators won't do, cause we do not store them in a special way such that
they can be compared. We're just an index right now.

Baloo::Term term("width", 500);
Baloo::Term term2("height", 200);

Baloo::Query q(term && term2);
q.exec();

Fetching Image Size -
Baloo::FileFetchJob job(file);
job->exec();
Baloo::File file = job->file();
file.property(KFileMetaData::Property::Width);


> 5. Is there a way to get types from query results? For example, I
> query "File" and then want to sort "Images", "Documents", "Videos" etc.
> Of course it can be done with KMimeType::findByUrl() but as this info
> is already stored by Baloo, maybe there's a better way?
>

Perhaps, we should expose something better.

I'm sorry, it seems that almost all of your use cases do not seem to really
work out right now. Our main focus was getting searching to work really
fast with the KDE tools being used - Dolphin, KRunner, KMail, etc.

-- 
Vishesh Handa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/nepomuk/attachments/20140618/f223928c/attachment.html>


More information about the Nepomuk mailing list