Honor position attribute, i.e. allow first-in-field search. To
[idzebra-moved-to-github.git] / index / zserver.c
index 565e652..ceeb56f 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: zserver.c,v 1.145 2006-03-31 15:58:04 adam Exp $
-   Copyright (C) 1995-2005
+/* $Id: zserver.c,v 1.149 2006-08-14 10:40:15 adam Exp $
+   Copyright (C) 1995-2006
    Index Data ApS
 
 This file is part of the Zebra server.
@@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra.  If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 */
 
 #include <assert.h>
@@ -251,15 +251,15 @@ static void search_terms(ZebraHandle zh, bend_search_rr *r)
         se->subqueryExpression->u.term->termComment = 0;
         se->subqueryInterpretation = 0;
         se->subqueryRecommendation = 0;
-       if (count > 2000000000)
-           count = 2000000000;
-        se->subqueryCount = odr_intdup(r->stream, (int) count);
+       if (count > 2147483646)
+           count = 2147483647;
+        se->subqueryCount = odr_intdup(r->stream, CAST_ZINT_TO_INT(count));
         se->subqueryWeight = 0;
         se->resultsByDB = 0;
     }
 }
 
-int bend_search (void *handle, bend_search_rr *r)
+int bend_search(void *handle, bend_search_rr *r)
 {
     ZebraHandle zh = (ZebraHandle) handle;
     zint zhits = 0;
@@ -282,10 +282,9 @@ int bend_search (void *handle, bend_search_rr *r)
            zebra_result(zh, &r->errcode, &r->errstring);
        else
        {
-           if (zhits >   2147483646)
-               r->hits = 2147483647;
-           else
-           r->hits = (int) zhits;
+           if (zhits > 2147483646)
+               zhits = 2147483647;
+            r->hits = CAST_ZINT_TO_INT(zhits);
             search_terms (zh, r);
        }
         break;
@@ -369,7 +368,8 @@ static int bend_scan (void *handle, bend_scan_rr *r)
        for (i = 0; i < r->num_entries; i++)
        {
            r->entries[i].term = entries[i].term;
-           r->entries[i].occurrences = entries[i].occurrences;
+           r->entries[i].occurrences =
+                CAST_ZINT_TO_INT(entries[i].occurrences);
        }
     }
     else
@@ -841,3 +841,11 @@ int main (int argc, char **argv)
 
     return statserv_main (argc, argv, bend_init, bend_close);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+