[gnome-applets/tracker-3: 1/2] tracker-search-bar: Apply FTS search across content and file data
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/tracker-3: 1/2] tracker-search-bar: Apply FTS search across content and file data
- Date: Sat, 6 Feb 2021 14:44:48 +0000 (UTC)
commit 3d90d08dd903bb92f6c844c41ea0596ff8f9c2f8
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 6 15:12:27 2021 +0100
tracker-search-bar: Apply FTS search across content and file data
Prior to Tracker 3, there was no split between content and file data,
so fts:match would look across fulltext-search properties on either
side of the split (e.g. text content or filename, indistinctly).
Preserve this same behavior for Tracker 3.x, while keeping queries
compatible with Tracker 2.x (although fairly redundant there). In
exchange for the query complication, the file query had been
generalized so they use a common template.
.../tracker-search-bar/tracker-results-window.c | 84 +++++++---------------
1 file changed, 25 insertions(+), 59 deletions(-)
---
diff --git a/gnome-applets/tracker-search-bar/tracker-results-window.c
b/gnome-applets/tracker-search-bar/tracker-results-window.c
index 54a7c354d..0aaf11e8f 100644
--- a/gnome-applets/tracker-search-bar/tracker-results-window.c
+++ b/gnome-applets/tracker-search-bar/tracker-results-window.c
@@ -33,71 +33,37 @@
#define MAX_ITEMS 10
-#define MUSIC_QUERY \
+#define FILE_SEARCH_QUERY(rdftype) \
"SELECT" \
" ?uri ?title ?tooltip ?uri fts:rank(?urn) " \
"WHERE {" \
- " ?content a nfo:Audio ;" \
- " nie:isStoredAs ?urn ." \
- " ?urn nie:url ?uri ; " \
- " nfo:fileName ?title ;" \
- " nfo:belongsToContainer ?tooltip ." \
- " ?urn fts:match \"%s*\" " \
+ " { " \
+ " { " \
+ " ?urn a " #rdftype "; " \
+ " nie:isStoredAs ?file . " \
+ " ?file nie:url ?uri ; " \
+ " nfo:belongsToContainer ?tooltip ; " \
+ " nfo:fileName ?title . " \
+ " } UNION { " \
+ " ?urn a nfo:FileDataObject ; " \
+ " nie:url ?uri ; " \
+ " nfo:belongsToContainer ?tooltip ; " \
+ " nfo:fileName ?title . " \
+ " ?content a " #rdftype "; " \
+ " nie:isStoredAs ?urn . " \
+ " } " \
+ " } " \
+ " ?urn fts:match \"%s*\" . " \
"}" \
"ORDER BY DESC(fts:rank(?urn)) " \
"OFFSET 0 LIMIT %d"
-#define IMAGE_QUERY \
- "SELECT" \
- " ?uri ?title ?tooltip ?uri fts:rank(?urn) " \
- "WHERE {" \
- " ?content a nfo:Image ;" \
- " nie:isStoredAs ?urn ." \
- " ?urn nie:url ?uri ; " \
- " nfo:fileName ?title ;" \
- " nfo:belongsToContainer ?tooltip ." \
- " ?urn fts:match \"%s*\" " \
- "} " \
- "ORDER BY DESC(fts:rank(?urn)) " \
- "OFFSET 0 LIMIT %d"
-#define VIDEO_QUERY \
- "SELECT" \
- " ?uri ?title ?tooltip ?uri fts:rank(?urn) " \
- "WHERE {" \
- " ?content a nmm:Video ;" \
- " nie:isStoredAs ?urn ." \
- " ?urn nie:url ?uri ; " \
- " nfo:fileName ?title ;" \
- " nfo:belongsToContainer ?tooltip ." \
- " ?urn fts:match \"%s*\" " \
- "} " \
- "ORDER BY DESC(fts:rank(?urn)) " \
- "OFFSET 0 LIMIT %d"
-#define DOCUMENT_QUERY \
- "SELECT" \
- " ?uri ?title ?tooltip ?uri fts:rank(?urn) " \
- "WHERE {" \
- " ?content a nfo:Document ;" \
- " nie:isStoredAs ?urn ." \
- " ?urn nie:url ?uri ; " \
- " nfo:fileName ?title ;" \
- " nfo:belongsToContainer ?tooltip ." \
- " ?urn fts:match \"%s*\" " \
- "} " \
- "ORDER BY DESC(fts:rank(?urn)) " \
- "OFFSET 0 LIMIT %d"
-#define FOLDER_QUERY \
- "SELECT" \
- " ?uri ?title ?tooltip ?uri fts:rank(?urn) " \
- "WHERE {" \
- " ?content a nfo:Folder ;" \
- " nie:isStoredAs ?urn ." \
- " ?urn nie:url ?uri ; " \
- " nfo:fileName ?title ;" \
- " nfo:belongsToContainer ?tooltip ." \
- " ?urn fts:match \"%s*\" " \
- "} " \
- "ORDER BY DESC(fts:rank(?urn)) " \
- "OFFSET 0 LIMIT %d"
+
+#define MUSIC_QUERY FILE_SEARCH_QUERY(nfo:Audio)
+#define IMAGE_QUERY FILE_SEARCH_QUERY(nfo:Image)
+#define VIDEO_QUERY FILE_SEARCH_QUERY(nmm:Video)
+#define DOCUMENT_QUERY FILE_SEARCH_QUERY (nfo:Document)
+#define FOLDER_QUERY FILE_SEARCH_QUERY (nfo:Folder)
+
#define APP_QUERY \
"SELECT" \
" ?urn ?title ?tooltip ?link fts:rank(?urn) nfo:softwareIcon(?urn)" \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]