Spotlight: FILTER in generated query doesn't handle nested directories with spaces
Mike M Pestorich
mmpestorich at gmail.com
Fri Aug 19 09:56:32 UTC 2016
I followed the directions at https://wiki.samba.org/index.php/Spotlight <https://wiki.samba.org/index.php/Spotlight> and at first glance everything seemed to be working great. However I noticed that if I run a search from within a nested directory that directory’s path contains spaces the query always returns no results.
I turned on debug logging and noticed that the sparql query generated looks like the following:
9 Aug 2016, 02:24:15: Tracker: <--- [21|smbd|7822] Steroids.Query
19 Aug 2016, 02:24:15: Tracker: ---- [21|smbd|7822] query: SELECT ?url WHERE { ?obj fts:match 'Deposit*' . ?obj nie:url ?url . FILTER(tracker:uri-is-descendant('file:///srv/smb/Groups/My Folder/Deposits/2011/', ?url)) }
19 Aug 2016, 02:24:15: Tracker: ---> [21|smbd|7822] Success, no error given
And no results are returned. Then I ran the generated query directly with “tracker sprawl -q”:
tracker sparql -q "SELECT ?url WHERE { ?obj fts:match 'Deposit*' . ?obj nie:url ?url . FILTER(tracker:uri-is-descendant('file:///srv/smb/Groups/My Folder/Deposits/2011/', ?url)) }”
And no results were returned. However, if I slightly modify it by escaping this space in the directory path:
tracker sparql -q "SELECT ?url WHERE { ?obj fts:match 'Deposit*' . ?obj nie:url ?url . FILTER(tracker:uri-is-descendant('file:///srv/smb/Groups/My%20Folder/Deposits/2011/', ?url)) }”
The correct results are returned.
I briefly looked through the code and I believe that “map_spotlight_to_sparql_query” in “samba/source3/rpc_server/mdssvc/sparql_parser.c” should be url encoding the directory path when generating the “FILTER” statement.
More information about the samba-technical
mailing list