-/* $Id: zebraapi.c,v 1.125 2004-08-10 08:54:39 heikki Exp $
+/* $Id: zebraapi.c,v 1.127 2004-08-25 09:23:36 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <yaz/sortspec.h>
#include "index.h"
#include <charmap.h>
-#include "zebraapi.h"
+#include <idzebra/api.h>
/* simple asserts to validate the most essential input args */
#define ASSERTZH assert(zh && zh->service)
int zebra_search_RPN (ZebraHandle zh, ODR o,
Z_RPNQuery *query, const char *setname, int *hits)
{
+ const char *max;
+ zint maxhits;
ASSERTZH;
yaz_log(LOG_API,"zebra_search_rpn");
zh->errCode=0;
zh->num_basenames, zh->basenames, setname);
zebra_end_read (zh);
- if (zh->hits > INT_MAX)
- *hits=INT_MAX;
+ max = res_get (zh->res, "maxhits");
+ if (max)
+ maxhits=atoi(max);
+ else {
+ int i=0;
+ maxhits=INT_MAX;
+ while (maxhits>100) { maxhits/=10; i++;}
+ while (i--) maxhits *= 10;
+ }
+ if (zh->hits > maxhits) { /* too large for yaz to handle */
+ logf(LOG_LOG,"limiting hits to "ZINT_FORMAT, maxhits);
+ *hits=maxhits; /* round it down to two digits, to look like rounded */
+ }
else
*hits = zh->hits;
return 0;