</varlistentry>
<varlistentry>
- <term>relevance / sort / mergekey</term>
+ <term>relevance / sort / mergekey / facet</term>
<listitem>
<para>
- Specifies character set normalization for relevancy / sorting
- and the mergekey - for the server. These definitions serves as
+ Specifies character set normalization for relevancy / sorting /
+ mergekey and facets - for the server. These definitions serves as
default for services that don't have these given. For the meaning
of these settings refer to the "relevance" element inside service.
</para>
</varlistentry>
<varlistentry>
+ <term>facet</term>
+ <listitem>
+ <para>
+ Specifies ICU tokenization and transformation rules
+ for tokens that are used in Pazpar2's facets. The contents
+ is similar to that of <literal>relevance</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>settings</term>
<listitem>
<para>
service->relevance_pct = 0;
service->sort_pct = 0;
service->mergekey_pct = 0;
+ service->facet_pct = 0;
service->id = service_id ? nmem_strdup(nmem, service_id) : 0;
service->num_metadata = num_metadata;
pp2_charset_destroy(service->relevance_pct);
pp2_charset_destroy(service->sort_pct);
pp2_charset_destroy(service->mergekey_pct);
+ pp2_charset_destroy(service->facet_pct);
yaz_mutex_destroy(&service->mutex);
nmem_destroy(service->nmem);
}
return 0;
}
}
+ else if (!strcmp((const char *) n->name, "facet"))
+ {
+ if (service->mergekey_pct)
+ {
+ yaz_log(YLOG_LOG, "facety may not repeat in service");
+ return 0;
+ }
+ else
+ {
+ service->facet_pct = pp2_charset_create_xml(n);
+ if (!service->mergekey_pct)
+ return 0;
+ }
+ }
else if (!strcmp((const char *) n->name, (const char *) "metadata"))
{
if (parse_metadata(service, n, &md_node, &sk_node))
}
}
- /* use relevance/sort/mergekey from server if not defined
+ /* use relevance/sort/mergekey/facet from server if not defined
for this service.. */
if (!s->relevance_pct)
{
else
s->mergekey_pct = pp2_charset_create(0);
}
+
+ if (!s->facet_pct)
+ {
+ if (server->facet_pct)
+ {
+ s->facet_pct = server->facet_pct;
+ pp2_charset_incref(s->facet_pct);
+ }
+ else
+ s->facet_pct = pp2_charset_create(0);
+ }
}
struct conf_service *service_create(struct conf_server *server,
server->relevance_pct = 0;
server->sort_pct = 0;
server->mergekey_pct = 0;
+ server->facet_pct = 0;
server->server_settings = 0;
server->http_server = 0;
server->iochan_man = 0;
if (!server->mergekey_pct)
return 0;
}
+ else if (!strcmp((const char *) n->name, "facet"))
+ {
+ server->facet_pct = pp2_charset_create_xml(n);
+ if (!server->facet_pct)
+ return 0;
+ }
else if (!strcmp((const char *) n->name, "service"))
{
char *service_id = (char *)
pp2_charset_destroy(server->relevance_pct);
pp2_charset_destroy(server->sort_pct);
pp2_charset_destroy(server->mergekey_pct);
+ pp2_charset_destroy(server->facet_pct);
yaz_log(YLOG_LOG, "server_destroy server=%p", server);
http_server_destroy(server->http_server);
}
pp2_charset_t relevance_pct;
pp2_charset_t sort_pct;
pp2_charset_t mergekey_pct;
+ pp2_charset_t facet_pct;
struct database *databases;
struct conf_targetprofiles *targetprofiles;
pp2_charset_t relevance_pct;
pp2_charset_t sort_pct;
pp2_charset_t mergekey_pct;
+ pp2_charset_t facet_pct;
+
struct conf_service *service;
struct conf_server *next;
struct conf_config *config;
void add_facet(struct session *s, const char *type, const char *value, int count)
{
- int i;
-
- if (!*value)
- return;
- for (i = 0; i < s->num_termlists; i++)
- if (!strcmp(s->termlists[i].name, type))
- break;
- if (i == s->num_termlists)
+ struct conf_service *service = s->service;
+ pp2_relevance_token_t prt;
+ const char *facet_component;
+ WRBUF facet_wrbuf = wrbuf_alloc();
+ prt = pp2_relevance_tokenize(service->facet_pct);
+
+ pp2_relevance_first(prt, value, 0);
+ while ((facet_component = pp2_relevance_token_next(prt)))
{
- if (i == SESSION_MAX_TERMLISTS)
+ if (*facet_component)
{
- session_log(s, YLOG_FATAL, "Too many termlists");
- return;
+ if (wrbuf_len(facet_wrbuf))
+ wrbuf_puts(facet_wrbuf, " ");
+ wrbuf_puts(facet_wrbuf, facet_component);
}
-
- s->termlists[i].name = nmem_strdup(s->nmem, type);
- s->termlists[i].termlist
- = termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
- s->num_termlists = i + 1;
}
- session_log(s, YLOG_DEBUG, "Session: facets for %s: %s (%d)",
- type, value, count);
-
- termlist_insert(s->termlists[i].termlist, value, count);
+ pp2_relevance_token_destroy(prt);
+
+ if (wrbuf_len(facet_wrbuf))
+ {
+ int i;
+ for (i = 0; i < s->num_termlists; i++)
+ if (!strcmp(s->termlists[i].name, type))
+ break;
+ if (i == s->num_termlists)
+ {
+ if (i == SESSION_MAX_TERMLISTS)
+ {
+ session_log(s, YLOG_FATAL, "Too many termlists");
+ wrbuf_destroy(facet_wrbuf);
+ return;
+ }
+
+ s->termlists[i].name = nmem_strdup(s->nmem, type);
+ s->termlists[i].termlist
+ = termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
+ s->num_termlists = i + 1;
+ }
+
+ session_log(s, YLOG_DEBUG, "Session: facets for %s: %s norm:%s (%d)",
+ type, value, wrbuf_cstr(facet_wrbuf), count);
+ termlist_insert(s->termlists[i].termlist, wrbuf_cstr(facet_wrbuf),
+ count);
+ }
+ wrbuf_destroy(facet_wrbuf);
}
static xmlDoc *record_to_xml(struct session *se,
<settings src="z3950_indexdata_com_marc.xml"/>
<relevance>
- <icu_chain id="relevance" locale="el">
+ <icu_chain locale="en">
<transform rule="[:Control:] Any-Remove"/>
<tokenize rule="l"/>
<transform rule="[[:WhiteSpace:][:Punctuation:]] Remove"/>
</relevance>
<sort>
- <icu_chain id="sort" locale="el">
+ <icu_chain locale="en">
<transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]] Remove"/>
<casemap rule="l"/>
</icu_chain>
</sort>
<mergekey>
- <icu_chain id="mergekey" locale="el">
+ <icu_chain locale="en">
<tokenize rule="l"/>
<transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]] Remove"/>
<casemap rule="l"/>
</icu_chain>
</mergekey>
+ <facet>
+ <icu_chain locale="en">
+ <tokenize rule="l"/>
+ <transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]] Remove"/>
+ <casemap rule="l"/>
+ </icu_chain>
+ </facet>
+
<service>
<metadata name="url" merge="unique"/>
--- /dev/null
+<termlist>
+<activeclients>0</activeclients>
+<list name="author">
+<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>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>cartography</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>
+<term><name>universities and colleges</name><frequency>1</frequency></term>
+<term><name>community colleges</name><frequency>1</frequency></term>
+</list>
+</termlist>
http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=title:1
http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=date:0
http://localhost:9763/search.pz2?session=1&command=show&start=0&number=1&sort=date:1
+http://localhost:9763/search.pz2?session=1&command=termlist&name=author%2Csubject