<?xml version="1.0" encoding="UTF-8"?>
<service xmlns="http://www.indexdata.com/pazpar2/1.0">
<timeout session="60" z3950_operation="30" z3950_session="180"/>
- <settings src="settings/sru-test.xml"/>
+ <settings src="settings/testserver.xml"/>
<icu_chain id="relevance" locale="en">
<transform rule="[:Control:] Any-Remove"/>
return 0;
}
-void client_start_search(struct client *cl)
+void client_start_search(struct client *cl, const char *sort_strategy,
+ const char *sort_spec)
{
struct session_database *sdb = client_get_database(cl);
struct connection *co = client_get_connection(cl);
ZOOM_query_cql(q, cl->cqlquery);
if (*opt_sort)
ZOOM_query_sortby(q, opt_sort);
+ if (sort_strategy && sort_spec)
+ {
+ yaz_log(YLOG_LOG, "applying %s %s", sort_strategy, sort_spec);
+ ZOOM_query_sortby2(q, sort_strategy, sort_spec);
+ }
rs = ZOOM_connection_search(link, q);
ZOOM_query_destroy(q);
}
else
{
+ ZOOM_query q = ZOOM_query_create();
+
yaz_log(YLOG_LOG, "Search %s PQF: %s", client_get_id(cl), cl->pquery);
- rs = ZOOM_connection_search_pqf(link, cl->pquery);
+
+ ZOOM_query_prefix(q, cl->pquery);
+
+ if (sort_strategy && sort_spec)
+ {
+ yaz_log(YLOG_LOG, "applying %s %s", sort_strategy, sort_spec);
+ ZOOM_query_sortby2(q, sort_strategy, sort_spec);
+ }
+ rs = ZOOM_connection_search(link, q);
+ ZOOM_query_destroy(q);
}
ZOOM_resultset_destroy(cl->resultset);
cl->resultset = rs;
int operation_timeout, int session_timeout,
iochan_man_t iochan,
const struct timeval *abstime);
-void client_start_search(struct client *cl);
+void client_start_search(struct client *cl, const char *sort_strategy,
+ const char *sort_spec);
void client_set_session(struct client *cl, struct session *se);
int client_is_active(struct client *cl);
int client_is_active_preferred(struct client *cl);
error(rs, PAZPAR2_MALFORMED_PARAMETER_VALUE, "sort");
release_session(c, s);
return;
+
}
struct http_request *rq = c->request;
struct http_session *s = locate_session(c);
const char *block = http_argbyname(rq, "block");
+ const char *sort = http_argbyname(rq, "sort");
+ struct reclist_sortparms *sp;
int status;
if (!s)
return;
+ if (!sort)
+ sort = "relevance";
+
status = session_active_clients(s->psession);
+ if (!(sp = reclist_parse_sortparms(c->nmem, sort, s->psession->service)))
+ {
+ error(c->response, PAZPAR2_MALFORMED_PARAMETER_VALUE, "sort");
+ release_session(c, s);
+ return;
+ }
+ search_sort(s->psession, sp->name, sp->increasing);
+
if (block)
{
if (!strcmp(block, "preferred") && !session_is_preferred_clients_ready(s->psession) && reclist_get_num_records(s->psession->reclist) == 0)
new->offset = offset;
new->type = type;
new->increasing = increasing;
+ new->name = nmem_strdup(nmem, parm);
rp = &new->next;
if (*(parms = cpp))
parms++;
int offset;
enum conf_sortkey_type type;
int increasing;
+ char *name;
struct reclist_sortparms *next;
};
return res == 0;
}
+void search_sort(struct session *se, const char *field, int increasing)
+{
+ struct client_list *l;
+ struct timeval tval;
+
+ session_enter(se);
+ for (l = se->clients; l; l = l->next)
+ {
+ struct client *cl = l->client;
+ struct session_database *sdb = client_get_database(cl);
+ struct setting *s;
+ const char *strategy_plus_sort = 0;
+
+ for (s = sdb->settings[PZ_SORTMAP]; s; s = s->next)
+ {
+ char *p = strchr(s->name + 3, ':');
+ if (!p)
+ {
+ yaz_log(YLOG_WARN, "Malformed sortmap name: %s", s->name);
+ continue;
+ }
+ p++;
+ if (!strcmp(p, field))
+ {
+ strategy_plus_sort = s->value;
+ break;
+ }
+ }
+
+ if (strategy_plus_sort)
+ {
+ if (client_prep_connection(cl, se->service->z3950_operation_timeout,
+ se->service->z3950_session_timeout,
+ se->service->server->iochan_man,
+ &tval))
+ {
+ char **array;
+ int num;
+ nmem_strsplit(se->nmem, ":", strategy_plus_sort, &array, &num);
+
+ if (num == 2)
+ {
+ const char *sort_spec = array[1];
+ while (*sort_spec == ' ')
+ sort_spec++;
+ client_start_search(cl, array[0], sort_spec);
+ }
+ }
+ }
+ }
+ session_leave(se);
+}
+
enum pazpar2_error_code search(struct session *se,
const char *query,
const char *startrecs, const char *maxrecs,
se->service->z3950_session_timeout,
se->service->server->iochan_man,
&tval))
- client_start_search(cl);
+ client_start_search(cl, 0, 0);
}
}
facet_limits_destroy(facet_limits);
void destroy_session(struct session *s);
void session_init_databases(struct session *s);
void statistics(struct session *s, struct statistics *stat);
+
+void search_sort(struct session *se, const char *field, int increasing);
+
enum pazpar2_error_code search(struct session *s, const char *query,
const char *startrecs, const char *maxrecs,
const char *filter, const char *limit,
"pz:facetmap:",
"pz:limitmap:",
"pz:url",
+ "pz:sortmap:",
0
};
#define PZ_FACETMAP 27
#define PZ_LIMITMAP 28
#define PZ_URL 29
-#define PZ_MAX_EOF 30
+#define PZ_SORTMAP 30
+#define PZ_MAX_EOF 31
struct setting
{
http://localhost:9763/search.pz2?command=init&clear=1&pz:elements%5Bmy%5D=F&pz:requestsyntax%5Bmy%5D=usmarc&pz:nativesyntax%5Bmy%5D=iso2709&pz:xslt%5Bmy%5D=marc21_test.xsl&pz:name%5Bmy%5D=marcserver&pz:url%5Bmy%5D=z3950.indexdata.com%2Fmarc
http://localhost:9763/search.pz2?session=1&command=search&query=computer
2 http://localhost:9763/search.pz2?session=1&command=show&block=1
-http://localhost:9763/search.pz2?session=1&command=settings&pz:url%5Bmy%5D=z3950.indexdata.com%2Fgils
+http://localhost:9763/search.pz2?session=1&command=settings&pz:url%5Bmy%5D=z3950.indexdata.com%2Fgils&pz:sortmap:title%5Bmy%5D=type7:title+%3C
http://localhost:9763/search.pz2?session=1&command=search&query=computer
2 http://localhost:9763/search.pz2?session=1&command=show&block=1
+2 http://localhost:9763/search.pz2?session=1&command=show&block=1&sort=title:1
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<show><status>OK</status>
+<activeclients>0</activeclients>
+<merged>3</merged>
+<total>3</total>
+<start>0</start>
+<num>3</num>
+<hit>
+
+<md-title>BIBLIOGRAPHY OF MAINE GEOLOGY</md-title>
+<md-description>This data base is a computer based bibliography of marine geology. It allows searching by topic and geographic location, similar to GEOREF. It is currently under development to replace the printed Bibliography of Marine Geology</md-description><location id="my" name="marcserver">
+<md-title>BIBLIOGRAPHY OF MAINE GEOLOGY</md-title>
+<md-description tag="520">This data base is a computer based bibliography of marine geology. It allows searching by topic and geographic location, similar to GEOREF. It is currently under development to replace the printed Bibliography of Marine Geology</md-description>
+<md-description tag="513">1692-PRESENT</md-description></location>
+<recid>title bibliography of maine geology author medium book</recid>
+</hit>
+<hit>
+
+<md-title>GROUNDWATER RESOURCE MAPS - COUNTY SERIES</md-title>
+<md-description>A series of 1:250,000 scale maps showing well yield, well depth, and depth to bedrock for a large number of bedrock wells inventoried by the Maine Geological Survey in the mid-to late 1970's comprises this data set. Some series also show bedrock topography and potentiometric surface. Geographic coverage is restricted to Southern Maine</md-description><location id="my" name="marcserver">
+<md-title>GROUNDWATER RESOURCE MAPS - COUNTY SERIES</md-title>
+<md-description tag="520">A series of 1:250,000 scale maps showing well yield, well depth, and depth to bedrock for a large number of bedrock wells inventoried by the Maine Geological Survey in the mid-to late 1970's comprises this data set. Some series also show bedrock topography and potentiometric surface. Geographic coverage is restricted to Southern Maine</md-description>
+<md-description tag="513">1972-1978</md-description></location>
+<recid>title groundwater resource maps county series author medium book</recid>
+</hit>
+<hit>
+
+<md-title>OIL/GAS DRILLING</md-title>
+<md-description>This database contains information on oil and gas drilling such as well name, operator, driller, location, depth, copies of logs run, permits, samples (cuttings, core), completion records</md-description><location id="my" name="marcserver">
+<md-title>OIL/GAS DRILLING</md-title>
+<md-description tag="520">This database contains information on oil and gas drilling such as well name, operator, driller, location, depth, copies of logs run, permits, samples (cuttings, core), completion records</md-description>
+<md-description tag="513">1907-PRESENT</md-description></location>
+<recid>title oil gas drilling author medium book</recid>
+</hit>
+</show>
\ No newline at end of file