[gtk+/tracker-updates-0.8: 3/3] tracker-search-engine: Improve search query to order by rank and title



commit 41a9ff36e2a8835dc4d172f7b0cb431b6d2cd0bc
Author: Martyn Russell <martyn lanedo com>
Date:   Fri Apr 9 13:01:05 2010 +0100

    tracker-search-engine: Improve search query to order by rank and title
    
    Also, query used ?file and ?urn so I think it was incorrect in the
    first place.

 gtk/gtksearchenginetracker.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtksearchenginetracker.c b/gtk/gtksearchenginetracker.c
index 81eb8f3..f684ece 100644
--- a/gtk/gtksearchenginetracker.c
+++ b/gtk/gtksearchenginetracker.c
@@ -204,7 +204,7 @@ static void
 sparql_append_string_literal (GString     *sparql,
                               const gchar *str)
 {
-	char *s;
+	gchar *s;
 
 	s = tracker_sparql_escape (str);
 
@@ -314,15 +314,15 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
 	if (tracker->priv->version == TRACKER_0_8 ||
 	    tracker->priv->version == TRACKER_0_9)
 		{
-			sparql = g_string_new ("SELECT ?url WHERE { ?file a nfo:FileDataObject; nie:url ?url; fts:match ");
+			sparql = g_string_new ("SELECT nie:url(?urn) WHERE { ?urn a nfo:FileDataObject; fts:match ");
 			sparql_append_string_literal (sparql, search_text);
 			if (location)
 				{
-					g_string_append (sparql, " . FILTER (fn:starts-with(?url,");
+					g_string_append (sparql, " . FILTER (fn:starts-with(nie:url(?urn),");
 					sparql_append_string_literal (sparql, location);
 					g_string_append (sparql, "))");
 				}
-			g_string_append (sparql, " }");
+			g_string_append (sparql, " } ORDER BY DESC(fts:rank(?urn)) ASC(nie:url(?urn))");
 
 			tracker_resources_sparql_query_async (tracker->priv->client,
 			                                      sparql->str,



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