 +
 +      /* fill with "uid1\0uid2\0uid3\0..." */
 +      dbt_fill_with_string_array (&id_dbt, uids);
-+
-+      {
-+        gchar *tmp = uids;
-+        for (; tmp && strlen (tmp); tmp += strlen (tmp) + 1) {
-+          g_debug (G_STRLOC ": adding to index with key %s and data %s", 
-+                   (gchar *)index_dbt.data, tmp);
-+        }
-+      }
  
        db_error = db->put (db, NULL, &index_dbt, &id_dbt, 0);
  
-@@ -714,13 +790,12 @@ generic_field_add (EBookBackendFileIndex
+@@ -714,13 +779,12 @@ generic_field_add (EBookBackendFileIndex
      EBookBackendFileIndexData *data, DB *db, const gchar *uid)
  {
    gchar *tmp = NULL;

+        gchar *tmp;
+        for (tmp = id_dbt.data; tmp && strlen (tmp); tmp += strlen (tmp) + 1) {
+          if (g_str_has_prefix (index_dbt.data, query_key)) {
+            g_debug (G_STRLOC ": index query found: %s for %s for %s", 
+                     (gchar *)tmp, query_key, (gchar *)index_dbt.data);
+            g_ptr_array_add (ids, tmp);
+
+            /* we add it to the list of strings to be freed */

--- evolution-data-server-lp/addressbook/backends/file/e-book-backend-file-index.c	2008-11-18 17:30:31.000000000 +0200
+++ evolution-data-server/addressbook/backends/file/e-book-backend-file-index.c	2008-11-18 17:55:52.000000000 +0200
@@ -476,7 +476,10 @@ e_book_backend_file_index_get_ordered_id
 
   while (db_error == 0)
