[gtk+/wip/cssnode3] searchenginetracker: Unify fts/non-fts query
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3] searchenginetracker: Unify fts/non-fts query
- Date: Sun, 1 Mar 2015 02:19:27 +0000 (UTC)
commit 10ca239849e415e39833656623d23d296b552198
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 28 22:59:36 2015 +0100
searchenginetracker: Unify fts/non-fts query
This makes sure we use location_uri for both types of query, and the fts
query has been made more similar to the one used by nautilus.
gtk/gtksearchenginetracker.c | 49 ++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtksearchenginetracker.c b/gtk/gtksearchenginetracker.c
index 6bc5e20..ae2d1de 100644
--- a/gtk/gtksearchenginetracker.c
+++ b/gtk/gtksearchenginetracker.c
@@ -245,7 +245,8 @@ sparql_escape_string (const gchar *literal)
static void
sparql_append_string_literal (GString *sparql,
- const gchar *str)
+ const gchar *str,
+ gboolean glob)
{
gchar *s;
@@ -253,6 +254,9 @@ sparql_append_string_literal (GString *sparql,
g_string_append_c (sparql, '"');
g_string_append (sparql, s);
+
+ if (glob)
+ g_string_append_c (sparql, '*');
g_string_append_c (sparql, '"');
g_free (s);
@@ -265,7 +269,7 @@ sparql_append_string_literal_lower_case (GString *sparql,
gchar *s;
s = g_utf8_strdown (str, -1);
- sparql_append_string_literal (sparql, s);
+ sparql_append_string_literal (sparql, s, FALSE);
g_free (s);
}
@@ -337,9 +341,7 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
{
GtkSearchEngineTracker *tracker;
gchar *search_text;
-#ifdef FTS_MATCHING
gchar *location_uri;
-#endif
GString *sparql;
tracker = GTK_SEARCH_ENGINE_TRACKER (engine);
@@ -357,37 +359,34 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
}
search_text = _gtk_query_get_text (tracker->priv->query);
-
-#ifdef FTS_MATCHING
location_uri = _gtk_query_get_location (tracker->priv->query);
- /* Using FTS: */
+
sparql = g_string_new ("SELECT nie:url(?urn) "
"WHERE {"
" ?urn a nfo:FileDataObject ;"
- " tracker:available true ; "
- " fts:match ");
- sparql_append_string_literal (sparql, search_text);
+ " tracker:available true ; ");
+
+#ifdef FTS_MATCHING
+ /* Using FTS: */
+ g_string_append (sparql, "fts:match ");
+ sparql_append_string_literal (sparql, search_text, TRUE);
+#endif
+
+ g_string_append (sparql, ". FILTER (fn:contains(fn:lower-case(nfo:fileName(?urn)),");
+ sparql_append_string_literal_lower_case (sparql, search_text);
if (location_uri)
{
- g_string_append (sparql, " . FILTER (fn:starts-with(nie:url(?urn),");
- sparql_append_string_literal (sparql, location_uri);
- g_string_append (sparql, "))");
+ g_string_append (sparql, ") && fn:starts-with(nie:url(?urn),");
+ sparql_append_string_literal (sparql, location_uri, FALSE);
}
- g_string_append (sparql, " } ORDER BY DESC(fts:rank(?urn)) ASC(nie:url(?urn))");
-#else /* FTS_MATCHING */
- /* Using filename matching: */
- sparql = g_string_new ("SELECT nie:url(?urn) "
- "WHERE {"
- " ?urn a nfo:FileDataObject ;"
- " tracker:available true ."
- " FILTER (fn:contains(fn:lower-case(nfo:fileName(?urn)),");
- sparql_append_string_literal_lower_case (sparql, search_text);
+ g_string_append (sparql, "))");
- g_string_append (sparql,
- "))"
- "} ORDER BY DESC(nie:url(?urn)) DESC(nfo:fileName(?urn))");
+#ifdef FTS_MATCHING
+ g_string_append (sparql, " } ORDER BY DESC(fts:rank(?urn)) DESC(nie:url(?urn))");
+#else /* FTS_MATCHING */
+ g_string_append (sparql, "} ORDER BY DESC(nie:url(?urn)) DESC(nfo:fileName(?urn))");
#endif /* FTS_MATCHING */
tracker->priv->query_pending = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]