Index: main/trunk/greenstone2/runtime-src/src/recpt/querytools.cpp
===================================================================
--- main/trunk/greenstone2/runtime-src/src/recpt/querytools.cpp	(revision 24017)
+++ main/trunk/greenstone2/runtime-src/src/recpt/querytools.cpp	(revision 24073)
@@ -738,14 +738,27 @@
   for (int i=0; i< values.size(); ++i) {
     if (!values[i].empty()) {
-      text_t this_value = values[i];
-
-      // remove operators for simple search, segments text if necessary
-      format_querystring(this_value, argb, segment); 
-           
-      // add tag info for this field (and other processing)
-      format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb);
-
-      const text_t DISTINCT_SELECT_WHERE
-	= "SELECT DISTINCT docOID FROM document_metadata WHERE ";
+	  text_t this_value;
+	  const text_t STARTINGWITH_CONDITION = "STARTINGWITH";
+	  const text_t LIKE_CONDITION = "LIKE";
+	  
+	  //Change the STARTINGWITH operator to 'LIKE' and then adds '%' to the end of the value field
+	  //in order to search a field starting with certain words.
+	  if (sqlcombs[i] == STARTINGWITH_CONDITION)
+		  {this_value = values[i];
+		  this_value += "%";
+		  // remove operators for simple search, segments text if necessary
+		  format_querystring(this_value, argb, segment); 
+		  // add tag info for this field (and other processing)
+		  format_field_info_sql(this_value, fields[i], LIKE_CONDITION, argt, argb);}
+
+	  else 
+		  {this_value = values[i];
+		  // remove operators for simple search, segments text if necessary
+		  format_querystring(this_value, argb, segment); 
+		  // add tag info for this field (and other processing)
+		  format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb);}
+
+	  
+      const text_t DISTINCT_SELECT_WHERE = "SELECT DISTINCT docOID FROM document_metadata WHERE ";
 
       if (querystring.empty()) {
@@ -808,16 +821,26 @@
 	else if (combs[i-1]=="not") { combine = "NOT"; }
       }
-      text_t this_value = values[i];
-
-      // remove operators for simple search, segments text if necessary
-      format_querystring(this_value, argb, segment); 
-
-      // add tag info for this field (and other processing)
-      format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb);
-
-      // add into query string
-
-      const text_t DISTINCT_SELECT_WHERE
-	= "SELECT DISTINCT docOID FROM document_metadata WHERE ";
+	  text_t this_value;
+	  const text_t STARTINGWITH_CONDITION = "STARTINGWITH";
+	  const text_t LIKE_CONDITION = "LIKE";
+	  
+	  //Change the STARTINGWITH operator to 'LIKE' and then adds '%' to the end of the value field
+	  //in order to search a field starting with certain words.
+	  if (sqlcombs[i] == STARTINGWITH_CONDITION)
+		  {this_value = values[i];
+		  this_value += "%";
+		  // remove operators for simple search, segments text if necessary
+		  format_querystring(this_value, argb, segment); 
+		  // add tag info for this field (and other processing)
+		  format_field_info_sql(this_value, fields[i], LIKE_CONDITION, argt, argb);}
+
+	  else 
+		  {this_value = values[i];
+		  // remove operators for simple search, segments text if necessary
+		  format_querystring(this_value, argb, segment); 
+		  // add tag info for this field (and other processing)
+		  format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb);}
+      
+      const text_t DISTINCT_SELECT_WHERE = "SELECT DISTINCT docOID FROM document_metadata WHERE ";
 
       if (querystring.empty()) {
@@ -980,4 +1003,5 @@
   element_in += tags_in + ") AND (";
 
+  
   if (sqlcomb == "=") {
     // override what it means to do equality, to make it more like full text
@@ -1025,4 +1049,20 @@
 
     element_in += orterms;
+  }
+  //We cast the value from STRING to REAL to allow numeric sorting
+  else if (sqlcomb == "<num") {
+    element_in += "CAST(value as REAL) < CAST('" + querystring+"' AS REAL)";
+  }
+  else if (sqlcomb == ">num") {
+    element_in += "CAST(value as REAL) > CAST('" + querystring+"' AS REAL)";
+  }
+   else if (sqlcomb == "<=num") {
+    element_in += "CAST(value as REAL) <= CAST('" + querystring+"' AS REAL)";
+  }
+  else if (sqlcomb == ">=num") {
+    element_in += "CAST(value as REAL) >= CAST('" + querystring+"' AS REAL)";
+  }
+  else if (sqlcomb == "=num") {
+    element_in += "CAST(value as REAL) = CAST('" + querystring+"' AS REAL)";
   }
   else {
