Index: contrib/luceneapi_node/luceneapi_node.index.inc
===================================================================
--- contrib/luceneapi_node/luceneapi_node.index.inc	(revision 2036)
+++ contrib/luceneapi_node/luceneapi_node.index.inc	(working copy)
@@ -53,10 +53,10 @@
        .' LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid'
        .' WHERE n.status = 1'
        .'   AND ('
-       .'     (GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR'
+       .'     (last_change = %d AND n.nid > %d) OR'
        .'     (n.changed > %d OR c.last_comment_timestamp > %d)'
        .'   )'
-       .' ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC';
+       .' ORDER BY last_change ASC, n.nid ASC';
 
   // adds statement to ignore excluded content types
   $sql = luceneapi_node_type_condition_add($sql);
@@ -321,7 +321,7 @@
        .' FROM {node} n'
        .' LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid'
        .' WHERE n.status = 1'
-       .' ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC';
+       .' ORDER BY last_change ASC, n.nid ASC';
 
   // finalizes SQL query, sets params dependent on $remaining
   $params = array();
@@ -330,7 +330,7 @@
 
     // adds condition to reindex remaining documents
     $replace = 'n.status = 1 AND ('
-             .'    (GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR'
+             .'    (last_change = %d AND n.nid > %d) OR'
              .'    (n.changed > %d OR c.last_comment_timestamp > %d)'
              .')';
     $sql = str_replace('n.status = 1', $replace, $sql);
