-/* $Id: zebraapi.h,v 1.3 2003-04-24 19:47:30 adam Exp $
+/* $Id: zebraapi.h,v 1.4 2003-05-20 12:52:49 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
Z_RPNQuery *query,
const char *setname, int *hits);
+YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh,
+ const char *pqf_query,
+ const char *setname);
+
/* Retrieve record(s) */
YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream,
const char *setname, Z_RecordComposition *comp,
* Admin
*/
-YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db);
+YAZ_EXPORT void zebra_create_database (ZebraHandle zh, const char *db);
YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh);
-/* $Id: index.h,v 1.98 2003-03-26 16:41:48 adam Exp $
+/* $Id: index.h,v 1.99 2003-05-20 12:52:49 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
int use, const char *term);
ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov);
ZebraSet resultSetGet (ZebraHandle zh, const char *name);
-ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode,
- Z_RPNQuery *rpn, int num_bases,
- char **basenames, const char *setname);
+ZebraSet resultSetAddRPN (ZebraHandle zh, Z_RPNQuery *rpn,
+ int num_bases, char **basenames,
+ const char *setname);
RSET resultSetRef (ZebraHandle zh, const char *resultSetId);
void resultSetDestroy (ZebraHandle zh, int num_names, char **names,
int *statuses);
-/* $Id: zebraapi.c,v 1.99 2003-05-13 13:52:12 adam Exp $
+/* $Id: zebraapi.c,v 1.100 2003-05-20 12:52:50 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
zebra_livcode_transform(zh, query);
- resultSetAddRPN (zh, decode, stream, query,
+ resultSetAddRPN (zh, query,
zh->num_basenames, zh->basenames, setname);
zebra_end_read (zh);
return 0;
}
-void zebra_admin_create (ZebraHandle zh, const char *database)
+void zebra_create_database (ZebraHandle zh, const char *database)
{
ZebraService zs;
ASSERTZH;
is not mandatory. (it's repeatable now, also in zebraapi.c)
*/
-void zebra_search_RPN (ZebraHandle zh, ODR decode, ODR stream,
- Z_RPNQuery *query, const char *setname, int *hits)
+void zebra_search_RPN (ZebraHandle zh, Z_RPNQuery *query,
+ const char *setname, int *hits)
{
zh->hits = 0;
*hits = 0;
if (zebra_begin_read (zh))
return;
- resultSetAddRPN (zh, decode, stream, query,
- zh->num_basenames, zh->basenames, setname);
+ resultSetAddRPN (zh, query, zh->num_basenames, zh->basenames, setname);
zebra_end_read (zh);
*hits = zh->hits;
}
-int zebra_search_PQF (ZebraHandle zh,
- ODR odr_input, ODR odr_output,
- const char *pqf_query,
+int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
const char *setname)
-
{
- int hits;
+ int hits = 0;
Z_RPNQuery *query;
- query = p_query_rpn (odr_input, PROTO_Z3950, pqf_query);
+ ODR odr = odr_createmem(ODR_ENCODE);
- if (!query) {
- logf (LOG_WARN, "bad query %s\n", pqf_query);
- odr_reset (odr_input);
- return(0);
- }
- zebra_search_RPN (zh, odr_input, odr_output, query, setname, &hits);
+ query = p_query_rpn (odr, PROTO_Z3950, pqf_query);
- odr_reset (odr_input);
- odr_reset (odr_output);
+ if (!query)
+ yaz_log (LOG_WARN, "bad query %s\n", pqf_query);
+ else
+ zebra_search_RPN (zh, query, setname, &hits);
- return(hits);
+ odr_destroy(odr);
+
+ return hits;
}
/* ---------------------------------------------------------------------------
-/* $Id: zserver.c,v 1.104 2003-03-04 23:30:20 adam Exp $
+/* $Id: zserver.c,v 1.105 2003-05-20 12:52:50 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
break;
case Z_ESAdminOriginPartToKeep_create:
yaz_log(LOG_LOG, "adm-create %s", r->toKeep->databaseName);
- zebra_admin_create (zh, r->toKeep->databaseName);
+ zebra_create_database (zh, r->toKeep->databaseName);
break;
case Z_ESAdminOriginPartToKeep_import:
yaz_log(LOG_LOG, "adm-import");
-/* $Id: zsets.c,v 1.44 2003-03-26 16:41:48 adam Exp $
+/* $Id: zsets.c,v 1.45 2003-05-20 12:52:50 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
struct zset_sort_entry **entries;
};
-ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output,
+ZebraSet resultSetAddRPN (ZebraHandle zh,
Z_RPNQuery *rpn, int num_bases,
char **basenames,
const char *setname)
zebraSet->basenames[i] = nmem_strdup (zebraSet->nmem, basenames[i]);
- zebraSet->rset = rpn_search (zh, output->mem, rpn,
+ zebraSet->rset = rpn_search (zh, zebraSet->nmem, rpn,
zebraSet->num_bases,
zebraSet->basenames, zebraSet->name,
zebraSet);
int force_update);
-/* == Search (zebra_api_ext.c) ============================================= */
+/* == Search (zebraapi.c) ================================================== */
%name(search_PQF)
int zebra_search_PQF (ZebraHandle zh,
- ODR odr_input, ODR odr_output,
const char *pqf_query,
const char *setname);
-
/* == YAZ - query tools ==================================================== */
-/* $Id: t2.c,v 1.4 2003-03-04 23:30:20 adam Exp $
+/* $Id: t2.c,v 1.5 2003-05-20 12:52:50 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
int main(int argc, char **argv)
{
+ int ret, hits;
ZebraService zs;
ZebraHandle zh;
const char *myrec =
nmem_init ();
- odr_input = odr_createmem (ODR_DECODE);
- odr_output = odr_createmem (ODR_ENCODE);
-
zs = zebra_start("t2.cfg");
zh = zebra_open (zs);
zebra_select_database(zh, "Default");
zebra_begin_trans (zh, 1);
zebra_record_insert (zh, myrec, strlen(myrec));
+
+ hits = zebra_search_PQF (zh, "@attr 1=4 my", "set1");
+ printf ("hits: %d\n", hits);
+
zebra_end_trans (zh);
zebra_commit (zh);
zebra_close (zh);
zebra_stop (zs);
- odr_destroy (odr_input);
- odr_destroy (odr_output);
-
nmem_exit ();
xmalloc_trav ("x");
exit (0);