Re: [Tracker] tracker-sparql -q QUERY shows results while exact same query via SPARQL C API doesn't



Hi Sam,

thanks for your reply, sorry for the late response. Your hints
somewhat helped moving in the right direction, but in the end what
helped most was bumping my head hard against a solid wall a few times.

2012/10/23 Sam Thursfield <ssssam gmail com>:
On Mon, Oct 22, 2012 at 10:38 AM, Frank Lahm <franklahm gmail com> wrote:
Hi,

is there anything wrong with this SPARQL query

  "SELECT ?url WHERE { ?f nie:url ?url . ?f nfo:fileName ?name .
FILTER(fn:starts-with(?url, 'file:///Volumes/test/') && regex(?name,
'unti')) }"

which would explain why tracker-sparql -q QUERY shows results:

frank$ tracker-sparql -q "SELECT ?url WHERE { ?f nie:url ?url . ?f
nfo:fileName ?name . FILTER(fn:starts-with(?url,
'file:///Volumes/test/') && regex(?name, 'unti')) }"
Ergebnisse:
  file:///Volumes/test/untitled%20text

...but the exact same query from a program [1] that uses the SPARQL C
API would give no result ?

I'm 100% sure it is the exact same query as I have a debug log
statement logging the query string it just a few lines before calling
tracker_sparql_connection_query():

One non-obvious thing that can change how queries are run is the
LOCALE / LC_COLLATE setting. If you have non-Western characters in
your results and your own C program is running in a different locale
to tracker-sparql for some reason, it might explain the issue. It
doesn't seem likely in this case though.

It wasn't the LOCALE settings.

  Oct 17 22:03:41.777237 afpd[27868] {spotlight_module.c:153}
(D5:Spotlight): sl_mod_start_search: SPARQL query:
  "SELECT ?url WHERE { ?f nie:url ?url . ?f nfo:fileName ?name .
FILTER(fn:starts-with(?url, 'file:///Volumes/test/') && regex(?name,
'test')) }"

Other SPARQL queries like

  "SELECT ?url WHERE { ?f nie:url ?url FILTER regex(?url, 'test')}"

work just fine from the program (and tracker-sparql). It seems as as
soon as I have FILTER expressions with more then one sub-expressions
(or more then one FILTER expression) I get this behaviour.

Unfortunately I can't seem to find a way to get Tracker to log debug
messages for the queries from the C program, the tracker-control
--set-log-verbosity=debug doesn't show me any query info at all (in
/root/.local/share/tracker/tracker-store.log).

I'm puzzled and would appreciate any pointers. Thanks!


By default libtracker-sparql uses direct access for read queries,
meaning that it loads the Tracker database in your application process
and executes the query there - therefore, the tracker-store logs won't
show any evidence of the access because the query didn't reach the
tracker-store process itself at all. Write queries always go over DBus
to the tracker-store process, so you should see logging information of
those.

I believe if you set TRACKER_VERBOSITY=3 in the environment of your C
program you'll see the logs of the queries that are being run
in-process.

I used this trick alongside redirecting stdout to the programs logile
(stdout is normally redirected to /dev/null as the program is a
network service deamon). Afair this pointed me in the right direction:
I'm using libtracker-sparql from a forking(!) network service daemon
(Opensource AFP fileserver Netatalk [1]). For some stupid reason I
initially placed the call to tracker_sparql_connection_get() in the
code which is executed in the parent process. Then later the queries
using this connection were executed by the forked childs.
As soon as I fixed this fatal flaw (tracker_sparql_connection_get() is
now executed from each child), the above query did work immediately.
This took two full days of debugging, so afterwards I got a little
unwilling to ever look back and send a reply. ;)

Thanks!

[1] <http://netatalk.sourceforge.net/wiki/index.php/Spotlight_Technology_Preview>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]