[brasero/wip/carlosg/tracker3: 3/5] Only use fts:rank with FTS searches
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [brasero/wip/carlosg/tracker3: 3/5] Only use fts:rank with FTS searches
- Date: Mon, 1 Feb 2021 22:45:26 +0000 (UTC)
commit f7181445bf9c88b7fab1bb5237d602b491694a9e
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Dec 24 13:04:03 2020 +0100
Only use fts:rank with FTS searches
This fixes two things:
- The use of fts:match depends on priv->keywords being set, but
fts:rank() has undefined behavior if fts:match is not present.
Its value is returned in the cursor, but fortunately unused,
so it can go away.
- Fixes "garbage" being added at the end of the query, concretely
") } ORDER BY ... " is appended at the supposed end of the query
string. Older SPARQL parser implementations would allow garbage
at the end of its parsing state, I suspect "LIMIT 0 OFFSET 10000"
was just a mean to push it to that state that it'd allow the
remaining string, so that is gone too.
src/brasero-search-tracker.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/brasero-search-tracker.c b/src/brasero-search-tracker.c
index 94085070..ae1d388a 100644
--- a/src/brasero-search-tracker.c
+++ b/src/brasero-search-tracker.c
@@ -234,7 +234,7 @@ brasero_search_tracker_query_start_real (BraseroSearchEngine *search,
priv = BRASERO_SEARCH_TRACKER_PRIVATE (search);
- query = g_string_new ("SELECT ?file ?url ?mime fts:rank(?file) " /* Which variables should be
returned */
+ query = g_string_new ("SELECT ?file ?url ?mime " /* Which variables should be
returned */
"WHERE {" /* Start defining the search
and its scope */
" ?file a nfo:FileDataObject . " /* File must be a file (not a
stream, ...) */
" ?file nie:url ?url . " /* Get the url of the file */
@@ -293,21 +293,18 @@ brasero_search_tracker_query_start_real (BraseroSearchEngine *search,
" ) ");
}
- if (priv->keywords)
+ if (priv->keywords) {
g_string_append_printf (query,
" ?file fts:match \"%s\" ", /* File must match possible
keywords */
priv->keywords);
- g_string_append (query,
- " } "
- "ORDER BY ASC(fts:rank(?file)) "
- "OFFSET 0 "
- "LIMIT 10000");
-
- g_string_append (query, ")");
-
- g_string_append (query,
- "} ORDER BY DESC(?url) DESC(nfo:fileName(?file))");
+ g_string_append (query,
+ " } "
+ "ORDER BY ASC(fts:rank(?file))");
+ } else {
+ g_string_append (query,
+ "} ORDER BY DESC(?url) DESC(nfo:fileName(?file))");
+ }
tracker_sparql_connection_query_async (priv->connection,
query->str,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]