</varlistentry>
<varlistentry>
- <term>pz:termlist_term_count</term>
- <listitem>
- <para>
- Specifies that the target should return up to n terms for each facets (where termlist="yes"). This implies
- that the target can return facets on the search command. Requesting facets on targets that doesn't,
- will return unpredictable or error result.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>pz:termlist_term_sort</term>
+ <term>pz:preferred</term>
<listitem>
<para>
- Specifies how the terms should be sorted. (Not yet implemented)
+ Specifies that a target is preferred, e.g. possible local, faster target. Using block=pref on show command
+ will wait for all these targets to return records before releasing the block. If no target is preferred,
+ the block=pref will identical to block=1, which release when one target has returned records.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>pz:preferred</term>
+ <term>pz:block_timeout</term>
<listitem>
<para>
- Specifies that a target is preferred, e.g. possible local, faster target. Using block=pref on show command
- will wait for all these targets to return records before releasing the block. If no target is preferred,
- the block=pref will identical to block=1, which release when one target has returned records.
+ (Not yet implemented). Specifies the time for which a block should be released anyway.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term>pz:block_timeout</term>
+ <term>pz:facetmap:<replaceable>name</replaceable></term>
<listitem>
<para>
- (Not yet implemented). Specifies the time for which a block should be released anyway.
+ Specifies that for field <replaceable>name</replaceable>, the target
+ supports (native) facets. The value is the name of the
+ field on the target.
</para>
+ <note>
+ <para>
+ At this point only SOLR targets have been tested with this
+ facility.
+ </para>
+ </note>
</listitem>
</varlistentry>
--- /dev/null
+<settings target="opencontent-solr.index:8984/solr">
+ <set name="pz:name" value="opencontent-solr"/>
+
+ <set name="pz:apdulog" value="1"/>
+ <!-- mapping for unqualified search -->
+ <set name="pz:cclmap:term" value="1=title"/>
+
+ <!-- field-specific mappings -->
+ <set name="pz:cclmap:au" value="1=author" />
+ <set name="pz:cclmap:ti" value="1=title" />
+ <set name="pz:cclmap:su" value="1=subject"/>
+ <set name="pz:cclmap:isbn" value="1=isbn" />
+ <set name="pz:cclmap:issn" value="1=issn" />
+ <set name="pz:cclmap:date" value="1=date" />
+
+ <!-- Retrieval settings -->
+
+ <set name="pz:sru" value="solr"/>
+ <set name="pz:requestsyntax" value="tmarc"/>
+
+ <!-- Termlist/facet settings -->
+ <set name="pz:termlist_term_count" value="0"/>
+ <set name="pz:termlist_term_sort" value="1"/>
+
+ <set name="pz:facetmap:date" value="date"/>
+ <set name="pz:facetmap:subject" value="subject_exact"/>
+ <set name="pz:facetmap:author" value="author_exact"/>
+ <!-- Result normalization settings -->
+
+ <set name="pz:nativesyntax" value="txml"/>
+ <set name="pz:xslt" value="solr-pz2.xsl"/>
+</settings>
+<!-- Keep this comment at the end of the file
+ Local variables:
+ mode: nxml
+ End:
+-->
+
* TODO Consider thread safety!!!
*
*/
-int client_report_facets(struct client *cl, ZOOM_resultset rs) {
+void client_report_facets(struct client *cl, ZOOM_resultset rs)
+{
int facet_idx;
+ struct session_database *sdb = client_get_database(cl);
ZOOM_facet_field *facets = ZOOM_resultset_facets(rs);
int facet_num;
struct session *se = client_get_session(cl);
+ struct setting *s;
facet_num = ZOOM_resultset_facets_size(rs);
yaz_log(YLOG_DEBUG, "client_report_facets: %d", facet_num);
- for (facet_idx = 0; facet_idx < facet_num; facet_idx++) {
- const char *name = ZOOM_facet_field_name(facets[facet_idx]);
- size_t term_idx;
- size_t term_num = ZOOM_facet_field_term_count(facets[facet_idx]);
- for (term_idx = 0; term_idx < term_num; term_idx++ ) {
- int freq;
- const char *term = ZOOM_facet_field_get_term(facets[facet_idx], term_idx, &freq);
- if (term)
- add_facet(se, name, term, freq);
+ for (s = sdb->settings[PZ_FACETMAP]; s; s = s->next)
+ {
+ const char *p = strchr(s->name + 3, ':');
+ if (p && p[1] && s->value && s->value[0])
+ {
+ p++; /* p now holds logical facet name */
+ for (facet_idx = 0; facet_idx < facet_num; facet_idx++)
+ {
+ const char *native_name =
+ ZOOM_facet_field_name(facets[facet_idx]);
+ if (native_name && !strcmp(s->value, native_name))
+ {
+ size_t term_idx;
+ size_t term_num =
+ ZOOM_facet_field_term_count(facets[facet_idx]);
+ for (term_idx = 0; term_idx < term_num; term_idx++ )
+ {
+ int freq;
+ const char *term =
+ ZOOM_facet_field_get_term(facets[facet_idx],
+ term_idx, &freq);
+ if (term)
+ add_facet(se, p, term, freq);
+ }
+ break;
+ }
+ }
}
}
-
- return 0;
}
static void ingest_raw_record(struct client *cl, ZOOM_record rec)
}
}
-static int client_set_facets_request(struct client *cl, ZOOM_connection link)
+static void client_set_facets_request(struct client *cl, ZOOM_connection link)
{
struct session_database *sdb = client_get_database(cl);
- const char *opt_facet_term_sort = session_setting_oneval(sdb, PZ_TERMLIST_TERM_SORT);
- const char *opt_facet_term_count = session_setting_oneval(sdb, PZ_TERMLIST_TERM_COUNT);
- /* Future record filtering on target */
- /* const char *opt_facet_record_filter = session_setting_oneval(sdb, PZ_RECORDFILTER); */
+ WRBUF w = wrbuf_alloc();
+
+ struct setting *s;
- /* Disable when no count is set */
- /* TODO Verify: Do we need to reset the ZOOM facets if a ZOOM Connection is being reused??? */
- if (opt_facet_term_count && *opt_facet_term_count)
+ for (s = sdb->settings[PZ_FACETMAP]; s; s = s->next)
{
- int index = 0;
- struct session *session = client_get_session(cl);
- struct conf_service *service = session->service;
- int num = service->num_metadata;
- WRBUF wrbuf = wrbuf_alloc();
- yaz_log(YLOG_DEBUG, "Facet settings, sort: %s count: %s",
- opt_facet_term_sort, opt_facet_term_count);
- for (index = 0; index < num; index++)
+ const char *p = strchr(s->name + 3, ':');
+ if (!p)
{
- struct conf_metadata *conf_meta = &service->metadata[index];
- if (conf_meta->termlist)
- {
- if (wrbuf_len(wrbuf))
- wrbuf_puts(wrbuf, ", ");
- wrbuf_printf(wrbuf, "@attr 1=%s", conf_meta->name);
-
- if (opt_facet_term_sort && *opt_facet_term_sort)
- wrbuf_printf(wrbuf, " @attr 2=%s", opt_facet_term_sort);
- wrbuf_printf(wrbuf, " @attr 3=%s", opt_facet_term_count);
- }
+ yaz_log(YLOG_WARN, "Malformed facetmap name: %s", s->name);
}
- if (wrbuf_len(wrbuf))
+ else if (s->value && s->value[0])
{
- yaz_log(YLOG_LOG, "Setting ZOOM facets option: %s", wrbuf_cstr(wrbuf));
- ZOOM_connection_option_set(link, "facets", wrbuf_cstr(wrbuf));
- return 1;
+ wrbuf_puts(w, "@attr 1=");
+ yaz_encode_pqf_term(w, s->value, strlen(s->value));
+ if (s->next)
+ wrbuf_puts(w, ",");
}
}
- return 0;
+ yaz_log(YLOG_LOG, "using facets str: %s", wrbuf_cstr(w));
+ ZOOM_connection_option_set(link, "facets",
+ wrbuf_len(w) ? wrbuf_cstr(w) : 0);
+ wrbuf_destroy(w);
}
-int client_has_facet(struct client *cl, const char *name) {
- ZOOM_facet_field facet_field;
- if (!cl || !cl->resultset || !name) {
- return 0;
- }
- facet_field = ZOOM_resultset_get_facet_field(cl->resultset, name);
- if (facet_field) {
- return 1;
+int client_has_facet(struct client *cl, const char *name)
+{
+ struct session_database *sdb = client_get_database(cl);
+ struct setting *s;
+
+ for (s = sdb->settings[PZ_FACETMAP]; s; s = s->next)
+ {
+ const char *p = strchr(s->name + 3, ':');
+ if (p && !strcmp(name, p + 1))
+ return 1;
}
return 0;
}
-
void client_start_search(struct client *cl)
{
struct session_database *sdb = client_get_database(cl);
return res == 0;
}
-
-
enum pazpar2_error_code search(struct session *se,
const char *query,
const char *startrecs, const char *maxrecs,
// construct facets ... unless the client already has reported them
if (ser_md->termlist && !client_has_facet(cl, (char *) type))
{
-
if (ser_md->type == Metadata_type_year)
{
char year[64];
"pz:negotiation_charset",
"pz:max_connections",
"pz:reuse_connections", /* PZ_REUSE_CONNECTION */
- "pz:termlist_term_sort", /* PZ_TERMLIST_TERM_SORT */
- "pz:termlist_term_count", /* PZ_TERMLIST_TERM_COUNT */
"pz:termlist_term_factor", /* PZ_TERMLIST_TERM_FACTOR*/
"pz:preferred", /* PZ_PREFERRED */
"pz:extra_args", /* PZ_EXTRA_ARGS */
"pz:query_syntax", /* PZ_QUERY_SYNTAX */
"pz:option_recordfilter", /* PZ_OPTION_RECORDFILTER */
-
+ "pz:facetmap:", /* PZ_FACETMAP */
0
};
#define PZ_NEGOTIATION_CHARSET 21
#define PZ_MAX_CONNECTIONS 22
#define PZ_REUSE_CONNECTIONS 23
-#define PZ_TERMLIST_TERM_SORT 24
-#define PZ_TERMLIST_TERM_COUNT 25
-#define PZ_TERMLIST_TERM_FACTOR 26
-#define PZ_PREFERRED 27
-#define PZ_EXTRA_ARGS 28
-#define PZ_QUERY_SYNTAX 29
-#define PZ_OPTION_RECORDFILTER 30
-#define PZ_MAX_EOF 31
+#define PZ_TERMLIST_TERM_FACTOR 24
+#define PZ_PREFERRED 25
+#define PZ_EXTRA_ARGS 26
+#define PZ_QUERY_SYNTAX 27
+#define PZ_OPTION_RECORDFILTER 28
+#define PZ_FACETMAP 29
+#define PZ_MAX_EOF 30
struct setting
{
http://localhost:9763/search.pz2?command=init&clear=1
-http://localhost:9763/search.pz2?session=1&command=settings&pz:name%5Blocalhost:9999%2Fdb1%5D=db1&pz:requestsyntax%5Blocalhost:9999%2Fdb1%5D=usmarc&pz:nativesyntax%5Blocalhost:9999%2Fdb1%5D=txml&pz:xslt%5Blocalhost:9999%2Fdb1%5D=tmarc.xsl&pz:termlist_term_count%5Blocalhost:9999%2Fdb1%5D=0
+http://localhost:9763/search.pz2?session=1&command=settings&pz:name%5Blocalhost:9999%2Fdb1%5D=db1&pz:requestsyntax%5Blocalhost:9999%2Fdb1%5D=usmarc&pz:nativesyntax%5Blocalhost:9999%2Fdb1%5D=txml&pz:xslt%5Blocalhost:9999%2Fdb1%5D=tmarc.xsl
http://localhost:9763/search.pz2?session=1&command=search&query=7+and+computer
http://localhost:9763/search.pz2?session=1&command=show&block=1
http://localhost:9763/search.pz2?session=1&command=bytarget
4 http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium
-http://localhost:9763/search.pz2?session=1&command=settings&pz:name%5Blocalhost:9999%2Fdb1%5D=db1&pz:requestsyntax%5Blocalhost:9999%2Fdb1%5D=usmarc&pz:nativesyntax%5Blocalhost:9999%2Fdb1%5D=txml&pz:xslt%5Blocalhost:9999%2Fdb1%5D=tmarc.xsl&pz:termlist_term_count%5Blocalhost:9999%2Fdb1%5D=5&pz:maxrecs%5Blocalhost:9999%2Fdb1%5D=2
+http://localhost:9763/search.pz2?session=1&command=settings&pz:name%5Blocalhost:9999%2Fdb1%5D=db1&pz:requestsyntax%5Blocalhost:9999%2Fdb1%5D=usmarc&pz:nativesyntax%5Blocalhost:9999%2Fdb1%5D=txml&pz:xslt%5Blocalhost:9999%2Fdb1%5D=tmarc.xsl&pz:maxrecs%5Blocalhost:9999%2Fdb1%5D=2&pz:facetmap:author%5Blocalhost:9999%2Fdb1%5D=author&pz:facetmap:subject%5Blocalhost:9999%2Fdb1%5D=subject&pz:facetmap:date%5Blocalhost:9999%2Fdb1%5D=date
http://localhost:9763/search.pz2?session=1&command=search&query=4+and+computer
http://localhost:9763/search.pz2?session=1&command=show&block=1
http://localhost:9763/search.pz2?session=1&command=bytarget
10 http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium
http://localhost:9763/search.pz2?session=1&command=bytarget
http://localhost:9763/search.pz2?command=init
-http://localhost:9763/search.pz2?session=2&command=settings&pz:name%5Blocalhost:9999%2Fdb1%5D=db1&pz:requestsyntax%5Blocalhost:9999%2Fdb1%5D=usmarc&pz:nativesyntax%5Blocalhost:9999%2Fdb1%5D=txml&pz:xslt%5Blocalhost:9999%2Fdb1%5D=tmarc.xsl&pz:apdulog%5Blocalhost:9999%2Fdb1%5D=1
+http://localhost:9763/search.pz2?session=2&command=settings&pz:name%5Blocalhost:9999%2Fdb1%5D=db1&pz:requestsyntax%5Blocalhost:9999%2Fdb1%5D=usmarc&pz:nativesyntax%5Blocalhost:9999%2Fdb1%5D=txml&pz:xslt%5Blocalhost:9999%2Fdb1%5D=tmarc.xsl&pz:apdulog%5Blocalhost:9999%2Fdb1%5D=1&pz:facetmap:date%5Blocalhost:9999%2Fdb1%5D=date
http://localhost:9763/search.pz2?session=2&command=search&query=9+and+computer
10 http://localhost:9763/search.pz2?session=2&command=show&block=1
http://localhost:9763/search.pz2?session=2&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium
<term><name>author2</name><frequency>80</frequency></term>
<term><name>author3</name><frequency>70</frequency></term>
<term><name>author4</name><frequency>60</frequency></term>
+<term><name>author5</name><frequency>50</frequency></term>
+<term><name>author6</name><frequency>40</frequency></term>
+<term><name>author7</name><frequency>30</frequency></term>
+<term><name>author8</name><frequency>20</frequency></term>
+<term><name>author9</name><frequency>10</frequency></term>
</list>
<list name="subject">
<term><name>subject0</name><frequency>100</frequency></term>
<term><name>subject2</name><frequency>80</frequency></term>
<term><name>subject3</name><frequency>70</frequency></term>
<term><name>subject4</name><frequency>60</frequency></term>
+<term><name>subject5</name><frequency>50</frequency></term>
+<term><name>subject6</name><frequency>40</frequency></term>
+<term><name>subject7</name><frequency>30</frequency></term>
+<term><name>subject8</name><frequency>20</frequency></term>
+<term><name>subject9</name><frequency>10</frequency></term>
</list>
<list name="date">
<term><name>date0</name><frequency>100</frequency></term>
<term><name>date2</name><frequency>80</frequency></term>
<term><name>date3</name><frequency>70</frequency></term>
<term><name>date4</name><frequency>60</frequency></term>
+<term><name>date5</name><frequency>50</frequency></term>
+<term><name>date6</name><frequency>40</frequency></term>
+<term><name>date7</name><frequency>30</frequency></term>
+<term><name>date8</name><frequency>20</frequency></term>
+<term><name>date9</name><frequency>10</frequency></term>
</list>
<list name="medium">
</list>
<term><name>author2</name><frequency>80</frequency></term>
<term><name>author3</name><frequency>70</frequency></term>
<term><name>author4</name><frequency>60</frequency></term>
+<term><name>author5</name><frequency>50</frequency></term>
+<term><name>author6</name><frequency>40</frequency></term>
+<term><name>author7</name><frequency>30</frequency></term>
+<term><name>author8</name><frequency>20</frequency></term>
+<term><name>author9</name><frequency>10</frequency></term>
</list>
<list name="subject">
<term><name>subject0</name><frequency>100</frequency></term>
<term><name>subject2</name><frequency>80</frequency></term>
<term><name>subject3</name><frequency>70</frequency></term>
<term><name>subject4</name><frequency>60</frequency></term>
+<term><name>subject5</name><frequency>50</frequency></term>
+<term><name>subject6</name><frequency>40</frequency></term>
+<term><name>subject7</name><frequency>30</frequency></term>
+<term><name>subject8</name><frequency>20</frequency></term>
+<term><name>subject9</name><frequency>10</frequency></term>
</list>
<list name="date">
<term><name>date0</name><frequency>100</frequency></term>
<term><name>date2</name><frequency>80</frequency></term>
<term><name>date3</name><frequency>70</frequency></term>
<term><name>date4</name><frequency>60</frequency></term>
+<term><name>date5</name><frequency>50</frequency></term>
+<term><name>date6</name><frequency>40</frequency></term>
+<term><name>date7</name><frequency>30</frequency></term>
+<term><name>date8</name><frequency>20</frequency></term>
+<term><name>date9</name><frequency>10</frequency></term>
</list>
<list name="medium">
</list>
<term><name>author2</name><frequency>80</frequency></term>
<term><name>author3</name><frequency>70</frequency></term>
<term><name>author4</name><frequency>60</frequency></term>
+<term><name>author5</name><frequency>50</frequency></term>
+<term><name>author6</name><frequency>40</frequency></term>
+<term><name>author7</name><frequency>30</frequency></term>
+<term><name>author8</name><frequency>20</frequency></term>
+<term><name>author9</name><frequency>10</frequency></term>
</list>
<list name="subject">
<term><name>subject0</name><frequency>100</frequency></term>
<term><name>subject2</name><frequency>80</frequency></term>
<term><name>subject3</name><frequency>70</frequency></term>
<term><name>subject4</name><frequency>60</frequency></term>
+<term><name>subject5</name><frequency>50</frequency></term>
+<term><name>subject6</name><frequency>40</frequency></term>
+<term><name>subject7</name><frequency>30</frequency></term>
+<term><name>subject8</name><frequency>20</frequency></term>
+<term><name>subject9</name><frequency>10</frequency></term>
</list>
<list name="date">
<term><name>date0</name><frequency>100</frequency></term>
<term><name>date2</name><frequency>80</frequency></term>
<term><name>date3</name><frequency>70</frequency></term>
<term><name>date4</name><frequency>60</frequency></term>
+<term><name>date5</name><frequency>50</frequency></term>
+<term><name>date6</name><frequency>40</frequency></term>
+<term><name>date7</name><frequency>30</frequency></term>
+<term><name>date8</name><frequency>20</frequency></term>
+<term><name>date9</name><frequency>10</frequency></term>
</list>
<list name="medium">
</list>
<term><name>author2</name><frequency>80</frequency></term>
<term><name>author3</name><frequency>70</frequency></term>
<term><name>author4</name><frequency>60</frequency></term>
+<term><name>author5</name><frequency>50</frequency></term>
+<term><name>author6</name><frequency>40</frequency></term>
+<term><name>author7</name><frequency>30</frequency></term>
+<term><name>author8</name><frequency>20</frequency></term>
+<term><name>author9</name><frequency>10</frequency></term>
</list>
<list name="subject">
<term><name>subject0</name><frequency>100</frequency></term>
<term><name>subject2</name><frequency>80</frequency></term>
<term><name>subject3</name><frequency>70</frequency></term>
<term><name>subject4</name><frequency>60</frequency></term>
+<term><name>subject5</name><frequency>50</frequency></term>
+<term><name>subject6</name><frequency>40</frequency></term>
+<term><name>subject7</name><frequency>30</frequency></term>
+<term><name>subject8</name><frequency>20</frequency></term>
+<term><name>subject9</name><frequency>10</frequency></term>
</list>
<list name="date">
<term><name>date0</name><frequency>100</frequency></term>
<term><name>date2</name><frequency>80</frequency></term>
<term><name>date3</name><frequency>70</frequency></term>
<term><name>date4</name><frequency>60</frequency></term>
+<term><name>date5</name><frequency>50</frequency></term>
+<term><name>date6</name><frequency>40</frequency></term>
+<term><name>date7</name><frequency>30</frequency></term>
+<term><name>date8</name><frequency>20</frequency></term>
+<term><name>date9</name><frequency>10</frequency></term>
</list>
<list name="medium">
</list>
</term>
</list>
<list name="author">
-<term><name>author0</name><frequency>100</frequency></term>
-<term><name>author1</name><frequency>90</frequency></term>
-<term><name>author2</name><frequency>80</frequency></term>
-<term><name>author3</name><frequency>70</frequency></term>
-<term><name>author4</name><frequency>60</frequency></term>
+<term><name>Jack Collins</name><frequency>2</frequency></term>
+<term><name>Mairs, John W</name><frequency>1</frequency></term>
+<term><name>Wood, Helen M</name><frequency>1</frequency></term>
+<term><name>Englund, Carl R</name><frequency>1</frequency></term>
</list>
<list name="subject">
-<term><name>subject0</name><frequency>100</frequency></term>
-<term><name>subject1</name><frequency>90</frequency></term>
-<term><name>subject2</name><frequency>80</frequency></term>
-<term><name>subject3</name><frequency>70</frequency></term>
-<term><name>subject4</name><frequency>60</frequency></term>
+<term><name>Radioisotope scanning</name><frequency>1</frequency></term>
+<term><name>Scintillation cameras</name><frequency>1</frequency></term>
+<term><name>Imaging systems in medicine</name><frequency>1</frequency></term>
+<term><name>Bible. O.T</name><frequency>1</frequency></term>
+<term><name>Bible</name><frequency>1</frequency></term>
+<term><name>Cartography</name><frequency>1</frequency></term>
+<term><name>Puget Sound region (Wash.)</name><frequency>1</frequency></term>
+<term><name>Tomography</name><frequency>1</frequency></term>
+<term><name>Optical pattern recognition</name><frequency>1</frequency></term>
+<term><name>Computers</name><frequency>1</frequency></term>
+<term><name>Railroads</name><frequency>1</frequency></term>
</list>
<list name="date">
<term><name>date0</name><frequency>100</frequency></term>
<term><name>date2</name><frequency>80</frequency></term>
<term><name>date3</name><frequency>70</frequency></term>
<term><name>date4</name><frequency>60</frequency></term>
+<term><name>date5</name><frequency>50</frequency></term>
+<term><name>date6</name><frequency>40</frequency></term>
+<term><name>date7</name><frequency>30</frequency></term>
+<term><name>date8</name><frequency>20</frequency></term>
+<term><name>date9</name><frequency>10</frequency></term>
</list>
<list name="medium">
</list>