return mergekey_norm;
}
+/** \brief see if metadata for pz:recordfilter exists
+ \param root xml root element of normalized record
+ \param sdb session database for client
+ \retval 0 if there is no metadata for pz:recordfilter
+ \retval 1 if there is metadata for pz:recordfilter
+
+ If there is no pz:recordfilter defined, this function returns 1
+ as well.
+*/
+
+static int check_record_filter(xmlNode *root, struct session_database *sdb)
+{
+ int match = 0;
+ xmlNode *n;
+ const char *s;
+ s = session_setting_oneval(sdb, PZ_RECORDFILTER);
+
+ if (!s || !*s)
+ return 1;
+
+ for (n = root->children; n; n = n->next)
+ {
+ if (n->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) n->name, "metadata"))
+ {
+ xmlChar *type = xmlGetProp(n, (xmlChar *) "type");
+
+ if (!type)
+ continue;
+ if (!strcmp((const char *) type, s))
+ {
+ xmlChar *value = xmlNodeGetContent(n);
+ if (value && *value)
+ {
+ xmlFree(value);
+ match = 1;
+ }
+ }
+ xmlFree(type);
+ }
+ }
+ return match;
+}
/** \brief ingest XML record
struct record *ingest_record(struct client *cl, const char *rec,
int record_no)
{
- xmlDoc *xdoc = normalize_record(client_get_database(cl),
- client_get_session(cl), rec);
+ struct session_database *sdb = client_get_database(cl);
+ xmlDoc *xdoc = normalize_record(sdb, client_get_session(cl), rec);
xmlNode *root, *n;
struct record *record;
struct record_cluster *cluster;
root = xmlDocGetRootElement(xdoc);
+ if (!check_record_filter(root, sdb))
+ {
+ yaz_log(YLOG_WARN, "Filtered out record no %d from %s", record_no,
+ sdb->database->url);
+ xmlFreeDoc(xdoc);
+ return 0;
+ }
+
mergekey_norm = get_mergekey(xdoc, cl, record_no, service, se->nmem);
if (!mergekey_norm)
{
--- /dev/null
+<show>
+<status>OK</status>
+<activeclients>0</activeclients>
+<merged>8</merged>
+<total>10</total>
+<start>0</start>
+<num>8</num>
+<hit>
+
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>The use of passwords for controlled access to computer resources</md-title>
+<md-date>1977</md-date>
+<md-author>Wood, Helen M</md-author>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title the use of passwords for controlled access to computer resources author wood helen m medium book</recid>
+</hit>
+<hit>
+
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date>
+<md-description>Cover title</md-description><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>A plan for community college computer development</md-title>
+<md-date>1971</md-date>
+<md-description>Cover title</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title a plan for community college computer development author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author>
+<md-description>"Contract DOT-UT-10003."</md-description><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>Washington metropolitan area rail computer feasibility study;</md-title>
+<md-title-remainder>final report</md-title-remainder>
+<md-date>1971</md-date>
+<md-author>Englund, Carl R</md-author>
+<md-description>"Contract DOT-UT-10003."</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title washington metropolitan area rail computer feasibility study author englund carl r medium book</recid>
+</hit>
+<hit>
+
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date>
+<md-description>Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>The Computer Bible</md-title>
+<md-date>1973-1980</md-date>
+<md-description>Hebrew and Greek; introductions in English</md-description>
+<md-description>Vols. 2, 8: Missoula, Mont. : Published by Scholars Press for Biblical Research Associates</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title the computer bible author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer science & technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>Computer science & technology</md-title>
+<md-title-remainder>proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, MD, June 3-4, 1976</md-title-remainder>
+<md-date>1977</md-date>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title computer science technology author medium book</recid>
+</hit>
+<hit>
+
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author>
+<md-description>Scale of maps ca. 1:1,000,000</md-description><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>The Puget Sound Region</md-title>
+<md-title-remainder>a portfolio of thematic computer maps</md-title-remainder>
+<md-date>1974</md-date>
+<md-author>Mairs, John W</md-author>
+<md-description>Scale of maps ca. 1:1,000,000</md-description>
+<md-description>Bibliography: p. 4</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title the puget sound region author mairs john w medium book</recid>
+</hit>
+<hit>
+
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date>
+<md-description>Includes bibliographical references and index</md-description><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>Computer processing of dynamic images from an Anger scintillation camera</md-title>
+<md-title-remainder>the proceedings of a workshop</md-title-remainder>
+<md-date>1974</md-date>
+<md-description>Includes bibliographical references and index</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title computer processing of dynamic images from an anger scintillation camera author medium book</recid>
+</hit>
+<hit>
+
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date>
+<md-description>Includes bibliographical references and index</md-description><location id="z3950.indexdata.com/marc" name="marc">
+<md-title>Reconstruction tomography in diagnostic radiology and nuclear medicine</md-title>
+<md-title-remainder>proceedings of the workshop</md-title-remainder>
+<md-date>1977</md-date>
+<md-description>Includes bibliographical references and index</md-description>
+<md-test-usersetting>XXXXXXXXXX</md-test-usersetting>
+<md-test-usersetting-2>test-usersetting-2 data:
+ YYYYYYYYY</md-test-usersetting-2></location>
+<recid>title reconstruction tomography in diagnostic radiology and nuclear medicine author medium book</recid>
+</hit>
+</show>