From: Adam Dickmeiss Date: Thu, 23 Oct 2008 10:09:34 +0000 (+0200) Subject: New attribute @fields for snippets that indicates match in other fields. X-Git-Tag: v2.0.34~8 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=e3f2abdb7863901fc997d5535ff512520edcbd0f New attribute @fields for snippets that indicates match in other fields. The snippets now has a new attribute @fields which includes one or more field names of where the snippet *also* occur. This is useful for any:w searches but one wants to know which other fields there is identical terms. Note that this requires that the indexing uses same sequence numbers . For DOM this means specifying the indexes in the same next) + { + /* same sequence but other field? */ + if (w->seqno == doc_w->seqno && w->ord != doc_w->ord) + { + const char *index_type; + const char *db = 0; + const char *string_index = 0; + + zebraExplain_lookup_ord(zh->reg->zei, w->ord, + &index_type, &db, &string_index); + /* only report for same index type */ + if (!strcmp(w_index_type, index_type)) + { + if (no == 0) + wrbuf_printf(wrbuf, " fields=\"%s", string_index); + else + wrbuf_printf(wrbuf, " %s", string_index); + no++; + } + } + } + if (no) + wrbuf_printf(wrbuf, "\""); +} + static void snippet_xml_record(ZebraHandle zh, WRBUF wrbuf, zebra_snippets *doc) { const zebra_snippet_word *doc_w; @@ -503,8 +538,11 @@ static void snippet_xml_record(ZebraHandle zh, WRBUF wrbuf, zebra_snippets *doc) if (mark_state == 0) { + wrbuf_printf(wrbuf, " ", index_type); + wrbuf_printf(wrbuf, " type=\"%s\"", index_type); + snippet_check_fields(zh, wrbuf, doc, doc_w, index_type); + wrbuf_printf(wrbuf, ">"); } if (doc_w->match) wrbuf_puts(wrbuf, ""); diff --git a/test/xslt/dom1.c b/test/xslt/dom1.c index e22dbfd..1d25fff 100644 --- a/test/xslt/dom1.c +++ b/test/xslt/dom1.c @@ -131,10 +131,10 @@ void tst(int argc, char **argv) YAZ_CHECK_EQ(tl_fetch_first_compare( zh, "zebra::snippet", yaz_oid_recsyn_xml, "\n" - " " + " " "Selected Prose of Oscar Wilde" "\n" - " " + " " "Wilde, Oscar, 1854-1900" "\n" ""),