[tracker/wip/fts4: 13/21] libtracker-data: Implement fts:snippet()



commit dc3040d0692d48ab1d9d1fb92e8e1ed0dd331095
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Dec 1 14:15:20 2011 +0100

    libtracker-data: Implement fts:snippet()
    
    this function takes up to 3 optional parameters after the
    object, the first 2 parameters are the starting/ending text
    for the match (defaults to <b></b>), and the third one
    modifies the ellipsis text (defaults to <b>...</b>)

 src/libtracker-data/tracker-sparql-expression.vala |   27 ++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-expression.vala b/src/libtracker-data/tracker-sparql-expression.vala
index 2dfa532..1ca4112 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -651,6 +651,33 @@ class Tracker.Sparql.Expression : Object {
 			sql.append ("tracker_offsets(offsets(\"fts\"),fts_property_names())");
 
 			return PropertyType.STRING;
+		} else if (uri == FTS_NS + "snippet") {
+			bool is_var;
+
+			string v = pattern.parse_var_or_term (null, out is_var);
+
+			sql.append_printf ("snippet(\"fts\"");
+
+			/* "start match" text */
+			if (accept (SparqlTokenType.COMMA)) {
+			      sql.append (", ");
+			      translate_expression_as_string (sql);
+
+			      /* "end match" text */
+			      expect (SparqlTokenType.COMMA);
+			      sql.append (", ");
+			      translate_expression_as_string (sql);
+			}
+
+			/* "ellipses" text */
+			if (accept (SparqlTokenType.COMMA)) {
+			      sql.append (", ");
+			      translate_expression_as_string (sql);
+			}
+
+			sql.append (")");
+
+			return PropertyType.STRING;
 		} else if (uri == TRACKER_NS + "id") {
 			var type = translate_expression (sql);
 			if (type != PropertyType.RESOURCE) {



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