Extend the ranking interface so staticrank is passed to calc method.
[idzebra-moved-to-github.git] / index / zserver.c
index 9e943b1..c0eacbe 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zserver.c,v 1.132 2005-05-11 12:39:37 adam Exp $
+/* $Id: zserver.c,v 1.138 2005-08-09 09:35:25 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,7 +28,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <io.h>
 #include <process.h>
 #include <sys/locking.h>
-#else
+#endif
+#if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
@@ -171,18 +172,15 @@ bend_initresult *bend_init (bend_initrequest *q)
     return r;
 }
 
-static void search_terms (ZebraHandle zh, bend_search_rr *r)
+static void search_terms(ZebraHandle zh, bend_search_rr *r)
 {
-    zint count = 0;
     int no_terms;
     int i;
     int type = Z_Term_general;
     struct Z_External *ext;
     Z_SearchInfoReport *sr;
 
-    /* get no of terms for result set */
-    no_terms = 0; /* zebra_resultSetTerms (zh, r->setname, 0, 0, 0, 0, 0); */
-      /* FIXME - Rsets don't know number of terms no more ??? */
+    zebra_result_set_term_no(zh, r->setname, &no_terms);
     if (!no_terms)
         return;
 
@@ -210,13 +208,15 @@ static void search_terms (ZebraHandle zh, bend_search_rr *r)
     for (i = 0; i<no_terms; i++)
     {
         Z_Term *term;
+       zint count;
+       int approx;
         char outbuf[1024];
         size_t len = sizeof(outbuf);
-        /* FIXME - Can we just skip this ??? */
-        /*
-        zebra_resultSetTerms (zh, r->setname, i,
-                              &count, &type, outbuf, &len);
-        */
+
+       zebra_result_set_term_info(zh, r->setname, i,
+                                  &count, &approx, outbuf, &len,
+                                  0 /* term_ref_id */ );
+
         sr->elements[i] = odr_malloc (r->stream, sizeof(**sr->elements));
         sr->elements[i]->subqueryId = 0;
         sr->elements[i]->fullQuery = odr_malloc (r->stream, 
@@ -311,7 +311,7 @@ int bend_fetch (void *handle, bend_fetch_rr *r)
     
     r->last_in_set = 0;
     res = zebra_records_retrieve (zh, r->stream, r->setname, r->comp,
-                           r->request_format, 1, &retrievalRecord);
+                                 r->request_format, 1, &retrievalRecord);
     if (res != ZEBRA_OK)
     {
        /* non-surrogate diagnostic */
@@ -359,7 +359,8 @@ static int bend_scan (void *handle, bend_scan_rr *r)
     res = zebra_scan(zh, r->stream, r->term,
                     r->attributeset,
                     &r->term_position,
-                    &r->num_entries, &entries, &is_partial);
+                    &r->num_entries, &entries, &is_partial, 
+                    0 /* setname */);
     if (res == ZEBRA_OK)
     {
        if (is_partial)
@@ -471,7 +472,6 @@ static int es_admin (ZebraHandle zh, Z_Admin *r)
     default:
        break;
     }
-
     return 0;
 }
 
@@ -561,11 +561,14 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr)
                 rr->errstring = "database";
                 return 0;
             }
-           if (notToKeep)
+           if (zebra_begin_trans(zh, 1) != ZEBRA_OK)
+           {
+               zebra_result(zh, &rr->errcode, &rr->errstring);
+           }
+           else
            {
                int i;
-                zebra_begin_trans (zh, 1);
-               for (i = 0; i < notToKeep->num; i++)
+               for (i = 0; notToKeep && i < notToKeep->num; i++)
                {
                    Z_External *rec = notToKeep->elements[i]->record;
                     struct oident *oident = 0;