de45ebf74df1 — Bill Welliver 4 years ago
full text: index binary data by only encoding content with mime type of "text/*"
2 files changed, 5 insertions(+), 4 deletions(-)

M modules/FullText.pmod/UpdateClient.pike
M plugins/fulltext/fulltext.pike
M modules/FullText.pmod/UpdateClient.pike +3 -2
@@ 38,11 38,12 @@ int delete_by_uuid(string uuid)
   return index_call("delete_by_uuid", uuid);
 }
 
-//!
+//! contents should be native pike wide strings (not utf8 encoded) if mime type is "text/*" or binary data.
 string add(string title, Calendar.Second date, string contents, string handle, string|void excerpt, string mimetype)
 {
+  if(has_prefix(mimetype, "text/")) contents = string_to_utf8(title);
   return index_call("add", string_to_utf8(title), date->unix_time(), 
-    MIME.encode_base64(string_to_utf8(contents)), string_to_utf8(handle), 
+    MIME.encode_base64((contents)), string_to_utf8(handle), 
     excerpt?string_to_utf8(excerpt):0, mimetype);
 }
 

          
M plugins/fulltext/fulltext.pike +2 -2
@@ 220,9 220,9 @@ void doUpdateIndex(string event, object 
 				get_preference("authcode")->get_value());
 
   string t = app->render(obj["current_version"]["contents"], obj, id);
-  logger->info("Adding content (%d bytes) to full text index.", sizeof(t));
+  logger->info("Adding content for %O (%d bytes) to full text index.", obj["title"], sizeof(t));
   if(obj["path"] && strlen(obj["path"]))
-  c->delete_by_handle(obj["path"]);  
+    c->delete_by_handle(obj["path"]);  
   c->add(obj["title"], 
       obj["current_version"]["created"], 
       t, obj["path"], 0,