From: Adam Dickmeiss Date: Tue, 6 Mar 2007 12:21:04 +0000 (+0000) Subject: Fixed bug #943: Searches with localid always find a hit. X-Git-Tag: ZEBRA.2.0.12~6 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=10fa93c4e981675844ea25e09882495a636e9e4e;p=idzebra-moved-to-github.git Fixed bug #943: Searches with localid always find a hit. --- diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 98fc69d..5ade0ea 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,4 +1,4 @@ -/* $Id: rpnsearch.c,v 1.8 2007-01-17 12:59:38 adam Exp $ +/* $Id: rpnsearch.c,v 1.9 2007-03-06 12:21:04 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -1886,21 +1886,35 @@ static ZEBRA_RES rpn_search_APT_local(ZebraHandle zh, RSET *rset, struct rset_key_control *kc) { - RSFD rsfd; - struct it_key key; - int sys; - *rset = rset_create_temp(rset_nmem, kc, kc->scope, - res_get (zh->res, "setTmpDir"),0 ); - rsfd = rset_open(*rset, RSETF_WRITE); + Record rec; + zint sysno = atozint(termz); - sys = atoi(termz); - if (sys <= 0) - sys = 1; - key.mem[0] = sys; - key.mem[1] = 1; - key.len = 2; - rset_write (rsfd, &key); - rset_close (rsfd); + if (sysno <= 0) + sysno = 0; + rec = rec_get(zh->reg->records, sysno); + if (!rec) + sysno = 0; + + rec_free(&rec); + + if (sysno <= 0) + { + *rset = rset_create_null(rset_nmem, kc, 0); + } + else + { + RSFD rsfd; + struct it_key key; + *rset = rset_create_temp(rset_nmem, kc, kc->scope, + res_get(zh->res, "setTmpDir"), 0); + rsfd = rset_open(*rset, RSETF_WRITE); + + key.mem[0] = sysno; + key.mem[1] = 1; + key.len = 2; + rset_write(rsfd, &key); + rset_close(rsfd); + } return ZEBRA_OK; }