FYI: Enable full tracker integration with nautilus 45+

In previous versions of nautilus, FTS could be fully enabled by simply adding the appropriate “FROM” to the search string in src/nautilus-search-engine-tracker.c.

Example:

--- nautilus-42.2-orig/src/nautilus-search-engine-tracker.c	2022-09-02 22:46:05.740683749 -0500
+++ nautilus-42.2/src/nautilus-search-engine-tracker.c	2022-09-02 22:51:19.515838433 -0500
@@ -364,7 +364,7 @@
 
     if (tracker->fts_enabled)
     {
-        g_string_append (sparql, "FROM tracker:Documents ");
+        g_string_append (sparql, "FROM tracker:Documents FROM tracker:Pictures FROM tracker:Audio FROM tracker:Video");
     }
 
     g_string_append (sparql,

It is a little different in nautilus 44, but essentially the same.

A quick and perhaps inelegant fix for nautilus 45.2

--- nautilus-45.2.1.orig/src/nautilus-search-engine-tracker.c	2023-12-06 04:03:31.000000000 -0600
+++ nautilus-45.2.1/src/nautilus-search-engine-tracker.c	2024-06-29 15:18:24.914066641 -0500
@@ -369,17 +369,55 @@
         {
             g_string_append (sparql,
                              " { "
-                             "   SELECT ?file " VARIABLES " {"
-                             "     GRAPH tracker:Documents {"
-                             "       ?file a nfo:FileDataObject ."
-                             "       ?content nie:isStoredAs ?file ."
-                             "       ?content fts:match ~match ."
-                             "       BIND(fts:rank(?content) AS ?rank) ."
-                             "       BIND(fts:snippet(?content,"
+                             "   SELECT ?file " VARIABLES " WHERE {"
+                             "     {"
+                             "       GRAPH tracker:Documents {"
+                             "         ?file a nfo:FileDataObject ."
+                             "         ?content nie:isStoredAs ?file ."
+                             "         ?content fts:match ~match ."
+                             "         BIND(fts:rank(?content) AS ?rank) ."
+                             "         BIND(fts:snippet(?content,"
                              "                        '_NAUTILUS_SNIPPET_DELIM_START_',"
                              "                        '_NAUTILUS_SNIPPET_DELIM_END_',"
                              "                        '…',"
                              "                        20) AS ?snippet)"
+                             "       }"
+                             "     } UNION {"
+                             "       GRAPH tracker:Pictures {"
+                             "         ?file a nfo:FileDataObject ."
+                             "         ?content nie:isStoredAs ?file ."
+                             "         ?content fts:match ~match ."
+                             "         BIND(fts:rank(?content) AS ?rank) ."
+                             "         BIND(fts:snippet(?content,"
+                             "                        '_NAUTILUS_SNIPPET_DELIM_START_',"
+                             "                        '_NAUTILUS_SNIPPET_DELIM_END_',"
+                             "                        '…',"
+                             "                        20) AS ?snippet)"
+                             "       }"
+                             "     } UNION {"
+                             "       GRAPH tracker:Audio {"
+                             "         ?file a nfo:FileDataObject ."
+                             "         ?content nie:isStoredAs ?file ."
+                             "         ?content fts:match ~match ."
+                             "         BIND(fts:rank(?content) AS ?rank) ."
+                             "         BIND(fts:snippet(?content,"
+                             "                        '_NAUTILUS_SNIPPET_DELIM_START_',"
+                             "                        '_NAUTILUS_SNIPPET_DELIM_END_',"
+                             "                        '…',"
+                             "                        20) AS ?snippet)"
+                             "       }"
+                             "     } UNION {"
+                             "       GRAPH tracker:Video {"
+                             "         ?file a nfo:FileDataObject ."
+                             "         ?content nie:isStoredAs ?file ."
+                             "         ?content fts:match ~match ."
+                             "         BIND(fts:rank(?content) AS ?rank) ."
+                             "         BIND(fts:snippet(?content,"
+                             "                        '_NAUTILUS_SNIPPET_DELIM_START_',"
+                             "                        '_NAUTILUS_SNIPPET_DELIM_END_',"
+                             "                        '…',"
+                             "                        20) AS ?snippet)"
+                             "       }"
                              "     }"
                              "     GRAPH tracker:FileSystem {"
                              TRIPLE_PATTERN

There is probably a more elegant way to do this, but
the hack works and the performance is good, even searching against an 8TB fs of old fashioned spinning disks :slight_smile:.

Enjoy!

1 Like

Hi. Welcome to our forums!

I’m not sure what you are trying to do. Why would FTS require adding graphs for Pictures, Audio, and Video?

I’ve just tested version 45 and full text search works as expected for my documents, without any patching.

The patch enables searching the metadata embedded in photos, songs, and video. For example, if I search my music library for “soundtrack”, I will get a list of all songs in that genre.

Oh, I see. That’s interesting and sounds useful.

I wonder why we have limited this to Documents then. Maybe there are undesirable side effects when adding other content types? Or adding too much noise to search results?

I’ve been using (or similar) hack for years across four, maybe five, different versions of nautilus. I have not noticed anything undesirable.