--- a/src/rcldb/rcldb.cpp
+++ b/src/rcldb/rcldb.cpp
@@ -105,6 +105,12 @@
     return pterm;
 }
 
+static inline void leftzeropad(string& s, unsigned len)
+{
+    if (s.length() && s.length() < len)
+	s = s.insert(0, len - s.length(), '0');
+}
+
 /* See comment in class declaration: return all subdocuments of a
  * document given by its unique id. 
 */
@@ -172,6 +178,7 @@
 	if (doc.meta.find(*it) == doc.meta.end()) 
 	    parms.get(*it, doc.meta[*it]);
     }
+    doc.meta[Doc::keymt] = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
     return true;
 }
 
@@ -861,12 +868,6 @@
 	m_synthAbsWordCtxLen = syntctxlen;
 }
 
-static inline void leftzeropad(string& s, unsigned len)
-{
-    if (s.length() && s.length() < len)
-	s = s.insert(0, len-s.length(), '0');
-}
-
 static const int MB = 1024 * 1024;
 static const string nc("\n\r\x0c");