// Initialize CCL map for a target
-static CCL_bibset prepare_cclmap(struct client *cl)
+static CCL_bibset prepare_cclmap(struct client *cl, CCL_bibset base_bibset)
{
struct session_database *sdb = client_get_database(cl);
struct setting *s;
if (!sdb->settings)
return 0;
- res = ccl_qual_mk();
+ if (base_bibset)
+ res = ccl_qual_dup(base_bibset);
+ else
+ res = ccl_qual_mk();
for (s = sdb->settings[PZ_CCLMAP]; s; s = s->next)
{
char *p = strchr(s->name + 3, ':');
static int apply_limit(struct session_database *sdb,
facet_limits_t facet_limits,
- WRBUF w_pqf, WRBUF w_ccl)
+ WRBUF w_pqf, WRBUF w_ccl,
+ CCL_bibset ccl_map)
{
int ret = 0;
int i = 0;
const char *name;
const char *value;
+ const char **and_op_names = ccl_qual_search_special(ccl_map, "and");
+ const char *and_op = and_op_names ? and_op_names[0] : "and";
+ const char **or_op_names = ccl_qual_search_special(ccl_map, "or");
+ const char *or_op = or_op_names ? or_op_names[0] : "or";
+
NMEM nmem_tmp = nmem_create();
for (i = 0; (name = facet_limits_get(facet_limits, i, &value)); i++)
{
else if (!strncmp(s->value, "ccl:", 4))
{
const char *ccl = s->value + 4;
-
- wrbuf_puts(w_ccl, " and (");
+
+ wrbuf_printf(w_ccl, " %s (", and_op);
for (i = 0; i < num; i++)
{
if (i)
- wrbuf_puts(w_ccl, " or ");
+ wrbuf_printf(w_ccl, " %s ", or_op);
wrbuf_puts(w_ccl, ccl);
wrbuf_puts(w_ccl, "=\"");
wrbuf_puts(w_ccl, values[i]);
// return -2 on limit error
int client_parse_query(struct client *cl, const char *query,
facet_limits_t facet_limits,
- const char *startrecs, const char *maxrecs)
+ const char *startrecs, const char *maxrecs,
+ CCL_bibset bibset)
{
struct session *se = client_get_session(cl);
struct session_database *sdb = client_get_database(cl);
struct ccl_rpn_node *cn;
int cerror, cpos;
ODR odr_out;
- CCL_bibset ccl_map = prepare_cclmap(cl);
+ CCL_bibset ccl_map = prepare_cclmap(cl, bibset);
const char *sru = session_setting_oneval(sdb, PZ_SRU);
const char *pqf_prefix = session_setting_oneval(sdb, PZ_PQF_PREFIX);
const char *pqf_strftime = session_setting_oneval(sdb, PZ_PQF_STRFTIME);
wrbuf_puts(w_pqf, " ");
}
- if (apply_limit(sdb, facet_limits, w_pqf, w_ccl))
+ if (apply_limit(sdb, facet_limits, w_pqf, w_ccl, ccl_map))
+ {
+ ccl_qual_rm(&ccl_map);
return -2;
+ }
facet_limits_destroy(cl->facet_limits);
cl->facet_limits = facet_limits_dup(facet_limits);
int client_parse_query(struct client *cl, const char *query,
facet_limits_t facet_limits, const char *startrecs,
- const char *maxrecs);
+ const char *maxrecs,
+ CCL_bibset bibset);
Odr_int client_get_hits(struct client *cl);
Odr_int client_get_approximation(struct client *cl);
int client_get_num_records(struct client *cl);
service->next = 0;
service->databases = 0;
service->xslt_list = 0;
+ service->ccl_bibset = 0;
service->server = server;
service->session_timeout = 60; /* default session timeout */
service->z3950_session_timeout = 180;
{
service_xslt_destroy(service);
pp2_charset_fact_destroy(service->charsets);
+ ccl_qual_rm(&service->ccl_bibset);
yaz_mutex_destroy(&service->mutex);
nmem_destroy(service->nmem);
}
}
}
}
+ else if (!strcmp((const char *) n->name, "ccldirective"))
+ {
+ char *name;
+ char *value;
+ if (!service->ccl_bibset)
+ service->ccl_bibset = ccl_qual_mk();
+ name = (char *) xmlGetProp(n, (xmlChar *) "name");
+ if (!name)
+ {
+ yaz_log(YLOG_FATAL, "ccldirective: missing @name");
+ return 0;
+ }
+ value = (char *) xmlGetProp(n, (xmlChar *) "value");
+ if (!value)
+ {
+ xmlFree(name);
+ yaz_log(YLOG_FATAL, "ccldirective: missing @value");
+ return 0;
+ }
+ ccl_qual_add_special(service->ccl_bibset, name, value);
+ xmlFree(value);
+ xmlFree(name);
+ }
else if (!strcmp((const char *) n->name, "settings"))
got_settings++;
else if (!strcmp((const char *) n->name, "icu_chain"))
#include <yaz/nmem.h>
#include <yaz/mutex.h>
+#include <yaz/ccl.h>
#include "charsets.h"
#include "http.h"
#include "database.h"
struct service_xslt *xslt_list;
+ CCL_bibset ccl_bibset;
struct database *databases;
struct conf_server *server;
};
continue;
parse_ret = client_parse_query(cl, query, facet_limits, startrecs,
- maxrecs);
+ maxrecs, se->service->ccl_bibset);
if (parse_ret == -1)
no_failed_query++;
else if (parse_ret == -2)
<proxy host="localhost"/>
<service>
+ <ccldirective name="and" value="AND"/>
+ <ccldirective name="or" value="OR"/>
+ <ccldirective name="not" value="NOT"/>
+
<include src="z3950_indexdata_com_marc.xml"/>
+
<metadata name="url" merge="unique"/>
<metadata name="title" brief="yes" sortkey="skiparticle" merge="longest" rank="6" mergekey="required" />
<metadata name="title-remainder" brief="yes" merge="longest" rank="5"/>
<metadata name="test-usersetting" brief="yes" setting="postproc"/>
<metadata name="test" setting="parameter"/>
<metadata name="test-usersetting-2" brief="yes"/>
+
</service>
<include src="*_service.xml"/>
http://localhost:9763/search.pz2?session=8&command=settings&pz:name%5Bz3950.indexdata.com%2Fmarc%5D=marc&pz:requestsyntax%5Bz3950.indexdata.com%2Fmarc%5D=usmarc&pz:nativesyntax%5Bz3950.indexdata.com%2Fmarc%5D=iso2709&pz:xslt%5Bz3950.indexdata.com%2Fmarc%5D=marc21%5Ftest.xsl&pz:recordfilter%5Bz3950.indexdata.com%2Fmarc%5D=date
http://localhost:9763/search.pz2?session=8&command=search&query=xyzzyz
2 http://localhost:9763/search.pz2?session=8&command=show&block=1
-http://localhost:9763/search.pz2?session=8&command=search&query=a+and
+http://localhost:9763/search.pz2?session=8&command=search&query=a+AND
1 http://localhost:9763/search.pz2?session=8&command=show&block=1
http://localhost:9763/search.pz2?command=init&pz:limitmap:author%5Bz3950.indexdata.com%2Fmarc%5D=ccl:author_phrase&pz:limitmap:Mysubject%5Bz3950.indexdata.com%2fmarc%5D=local:subject&pz:limitmap:date%5Bz3950.indexdata.com%2fmarc%5D=local:
1 http://localhost:9763/search.pz2?session=9&command=search&query=greece&limit=author%3Dadam\,+james%7Cother_author
http://localhost:9763/search.pz2?command=init
http://localhost:9763/search.pz2?session=10&command=search&query=au%3dadam
http://localhost:9763/search.pz2?session=10&command=show&block=1
+http://localhost:9763/search.pz2?session=10&command=search&query=teachers+AND+greece
+http://localhost:9763/search.pz2?session=10&command=show&block=1
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<search><status>OK</status></search>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<show><status>OK</status>
+<activeclients>0</activeclients>
+<merged>1</merged>
+<total>1</total>
+<start>0</start>
+<num>1</num>
+<hit>
+
+<md-title>The religious teachers of Greece</md-title>
+<md-date>1972</md-date>
+<md-author>Adam, James</md-author>
+<md-subject>Greek literature</md-subject>
+<md-subject>Philosophy, Ancient</md-subject>
+<md-subject>Greece</md-subject>
+<md-description>Reprint of the 1909 ed., which was issued as the 1904-1906 Gifford lectures</md-description><location id="z3950.indexdata.com/marc" name="Index Data MARC test server">
+<md-title>The religious teachers of Greece</md-title>
+<md-date>1972</md-date>
+<md-author>Adam, James</md-author>
+<md-subject>Greek literature</md-subject>
+<md-subject>Philosophy, Ancient</md-subject>
+<md-subject>Greece</md-subject>
+<md-description tag="500">Reprint of the 1909 ed., which was issued as the 1904-1906 Gifford lectures</md-description>
+<md-description tag="504">Includes bibliographical references</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<relevance>540000</relevance>
+<recid>content: title the religious teachers of greece author adam james medium book</recid>
+</hit>
+</show>
\ No newline at end of file