1 /* $Id: rpnfacet.c,v 1.2 2007-11-01 16:01:33 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <yaz/diagbib1.h>
32 #include <zebra_xpath.h>
33 #include <yaz/wrbuf.h>
37 #include <yaz/oid_db.h>
39 ZEBRA_RES rpn_facet(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
40 const Odr_oid *attributeset,
41 int *position, int *num_entries,
42 ZebraScanEntry **list, int *is_partial, RSET rset)
45 ZEBRA_RES res = zebra_attr_list_get_ord(zh,
47 zinfo_index_category_sort,
54 const char *index_type = 0;
56 const char *string_index = 0;
58 /* check that sort idx exist for ord */
59 /* sweep through result set and sort_idx at the same time */
60 char *this_entry_buf = xmalloc(SORT_IDX_ENTRYSIZE);
61 char *dst_buf = xmalloc(SORT_IDX_ENTRYSIZE);
62 size_t sysno_mem_index = 0;
69 if (zebraExplain_lookup_ord(zh->reg->zei,
70 ord, &index_type, &db, &string_index))
72 yaz_log(YLOG_WARN, "zebraExplain_lookup_ord failed");
78 rfd = rset_open(rset, RSETF_READ);
79 while (rset_read(rfd, &key, &termid))
81 zint sysno = key.mem[sysno_mem_index];
82 if (sysno != p_this_sys)
85 zebra_sort_sysno(zh->reg->sort_index, sysno);
86 zebra_sort_type(zh->reg->sort_index, ord);
87 zebra_sort_read(zh->reg->sort_index, this_entry_buf);
89 zebra_term_untrans(zh, index_type, dst_buf, this_entry_buf);
90 yaz_log(YLOG_LOG, "dst_buf=%s", dst_buf);
94 xfree(this_entry_buf);
96 zebra_setError(zh, YAZ_BIB1_TEMPORARY_SYSTEM_ERROR, "facet not done");
104 * indent-tabs-mode: nil
106 * vim: shiftwidth=4 tabstop=8 expandtab