*** empty log message ***
authorArt Cancro <ajc@citadel.org>
Tue, 17 May 2005 19:33:07 +0000 (19:33 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 17 May 2005 19:33:07 +0000 (19:33 +0000)
citadel/serv_fulltext.c
citadel/serv_fulltext.o
citadel/server.h

index 37bfc3cd2a7940eb24d3764bba04187f2294cf19..018ca9ab6b711554a0f05ae95de1904337e62733 100644 (file)
@@ -60,6 +60,8 @@ void ft_index_message(long msgnum, int op) {
        int num_tokens = 0;
        int *tokens = NULL;
        int i;
+       struct cdbdata *cdb_bucket;
+       int num_msgs;
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) return;
@@ -71,10 +73,26 @@ void ft_index_message(long msgnum, int op) {
 
        if (num_tokens > 0) {
                for (i=0; i<num_tokens; ++i) {
-                       /* FIXME do something with this */
-                       lprintf(CTDL_DEBUG, "msg %ld, token %d\n",
-                               msgnum, tokens[i]);
+
+                       /* Add the message to the relevant token bucket */
+                       lprintf(CTDL_DEBUG, "msg %ld, token %d\n", msgnum, tokens[i]);
+
+                       /* FIXME lock the file */
+                       cdb_bucket = cdb_fetch(CDB_FULLTEXT, &tokens[i], sizeof(long));
+                       if (cdb_bucket == NULL) {
+                               cdb_bucket = malloc(sizeof(struct cdbdata));
+                               cdb_bucket->len = 0;
+                               cdb_bucket->ptr = malloc(sizeof(long));
                        }
+                       num_msgs = cdb_bucket->len / sizeof(long);
+
+                       /* FIXME finish this */
+
+                       cdb_free(cdb_bucket);
+
+                       /* FIXME unlock the file */
+               }
+
                free(tokens);
        }
 }
@@ -128,8 +146,15 @@ int longcmp(const void *rec1, const void *rec2) {
  */
 void do_fulltext_indexing(void) {
        int i;
+       static time_t last_index = 0L;
 
-       lprintf(CTDL_DEBUG, "do_fulltext_indexing() started\n");
+       /*
+        * Make sure we don't run the indexer too frequently.
+        * FIXME move the setting into config
+        */
+       if ( (time(NULL) - last_index) < 300L) {
+               return;
+       }
 
        /*
         * Check to see whether the fulltext index is up to date; if there
@@ -140,19 +165,22 @@ void do_fulltext_indexing(void) {
        lprintf(CTDL_DEBUG, "CitControl.MMfulltext = %ld\n",
                CitControl.MMfulltext);
        if (CitControl.MMfulltext >= CitControl.MMhighest) {
-               lprintf(CTDL_DEBUG, "Nothing to do!\n");
+               /* nothing to do! */
                return;
        }
-       
-       /*
-        * Make sure we don't run the indexer too frequently.
-        * FIXME write this...
-        */
 
+       lprintf(CTDL_DEBUG, "do_fulltext_indexing() started\n");
+       
        /*
         * If we've switched wordbreaker modules, burn the index and start
         * over.  FIXME write this...
         */
+       if (CitControl.fulltext_wordbreaker != FT_WORDBREAKER_ID) {
+               lprintf(CTDL_INFO, "(re)initializing full text index\n");
+               cdb_trunc(CDB_FULLTEXT);
+               CitControl.MMfulltext = 0L;
+               put_control();
+       }
 
        /*
         * Now go through each room and find messages to index.
index 7661e3c19b4ddac642600165ef187258012ecae2..935d5092a8565a6dd2b12d1133d1b2db900450e4 100644 (file)
Binary files a/citadel/serv_fulltext.o and b/citadel/serv_fulltext.o differ
index 8281869e162ae524189f86fa0fb06570ef33c30b..5484129ce57e905e55fad7300eb27ac708fc7cc2 100644 (file)
@@ -261,6 +261,7 @@ enum {
        CDB_DIRECTORY,          /* address book directory        */
        CDB_USETABLE,           /* network use table             */
        CDB_BIGMSGS,            /* larger message bodies         */
+       CDB_FULLTEXT,           /* full text search index        */
        MAXCDB                  /* total number of CDB's defined */
 };