[tracker/wip/carlosg/update-perf: 4/61] core: Fix lookup of multivalued FTS columns




commit d1b55e87a5ab7dfe809af1ce1d52ec7dc07996ec
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Aug 22 11:52:18 2022 +0200

    core: Fix lookup of multivalued FTS columns
    
    When creating the FTS view, we would typically group_concat() those for
    FTS, but we are looking the wrong key here. We should be looking for
    the table name, not the column name.

 src/libtracker-sparql/core/tracker-fts.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-fts.c b/src/libtracker-sparql/core/tracker-fts.c
index 353685992..be351817b 100644
--- a/src/libtracker-sparql/core/tracker-fts.c
+++ b/src/libtracker-sparql/core/tracker-fts.c
@@ -91,8 +91,9 @@ tracker_fts_create_table (sqlite3      *db,
        /* Create view on tables/columns marked as FTS-indexed */
        str = g_string_new ("CREATE VIEW ");
        g_string_append_printf (str, "\"%s\".fts_view AS SELECT \"rdfs:Resource\".ID as rowid ",
-                               database);
-       from = g_string_new ("FROM \"rdfs:Resource\" ");
+                               database);
+       from = g_string_new (NULL);
+       g_string_append_printf (from, "FROM \"%s\".\"rdfs:Resource\" ", database);
 
        fts = g_string_new ("CREATE VIRTUAL TABLE ");
        g_string_append_printf (fts, "\"%s\".%s USING fts5(content=\"fts_view\", ",
@@ -107,7 +108,7 @@ tracker_fts_create_table (sqlite3      *db,
 
                while (columns) {
                        if (grouped_columns &&
-                           g_hash_table_lookup (grouped_columns, columns->data)) {
+                           g_hash_table_lookup (grouped_columns, index_table)) {
                                g_string_append_printf (str, ", group_concat(\"%s\".\"%s\")",
                                                        index_table,
                                                        (gchar *) columns->data);
@@ -132,6 +133,7 @@ tracker_fts_create_table (sqlite3      *db,
 
        g_list_free (keys);
 
+       g_string_append (from, "GROUP BY ROWID");
        g_string_append (str, from->str);
        g_string_free (from, TRUE);
 


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