]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/modules/autocompletion/serv_autocompletion.c
Rewrite of the indexer is complete!
[citadel.git] / citadel / server / modules / autocompletion / serv_autocompletion.c
index 3f025521fe76b4250c3d8851ddf68671758a7ac5..d8e04cb798166d4d84e900b9e2f436e200a9862e 100644 (file)
@@ -9,6 +9,7 @@
 #include "serv_autocompletion.h"
 #include "../../config.h"
 #include "../../room_ops.h"
+#include "../fulltext/serv_fulltext.h"
 
 
 // Convert a structured name into a friendly name.  Caller must free the
@@ -109,13 +110,12 @@ void cmd_auto(char *argbuf) {
        char search_string[256];
        long *msglist = NULL;
        int num_msgs = 0;
-       long *fts_msgs = NULL;
-       int fts_num_msgs = 0;
        int r = 0;
        int i = 0;
        int j = 0;
        int search_match = 0;
        char *rooms_to_try[] = { USERCONTACTSROOM, ADDRESS_BOOK_ROOM };
+       Array *fts = NULL;
                
        if (CtdlAccessCheck(ac_logged_in)) return;
        extract_token(search_string, argbuf, 0, '|', sizeof search_string);
@@ -134,21 +134,23 @@ void cmd_auto(char *argbuf) {
 
                        // Search-reduce the results if we have the full text index available
                        if (CtdlGetConfigInt("c_enable_fulltext")) {
-                               CtdlModuleDoSearch(&fts_num_msgs, &fts_msgs, search_string, "fulltext");
-                               if (fts_msgs) {
+                               fts = CtdlFullTextSearch(search_string);
+                               if (fts) {
                                        for (i=0; i<num_msgs; ++i) {
                                                search_match = 0;
-                                               for (j=0; j<fts_num_msgs; ++j) {
-                                                       if (msglist[i] == fts_msgs[j]) {
+                                               for (j=0; j<array_len(fts); ++j) {
+                                                       long smsgnum;
+                                                       memcpy(&smsgnum, array_get_element_at(fts, j), sizeof(long));
+                                                       if (msglist[i] == smsgnum) {
                                                                search_match = 1;
-                                                               j = fts_num_msgs + 1;   // end the search 
+                                                               j = array_len(fts) + 1; // end the search 
                                                        }
                                                }
                                                if (!search_match) {
                                                        msglist[i] = 0;                 // invalidate this result
                                                }
                                        }
-                                       free(fts_msgs);
+                                       array_free(fts);
                                }
                                else {
                                        // If no results, invalidate the whole list