Skip to main content.
home | support | download

Back to List Archive

Re: multiple instances of a property

From: Peter Karman <peter(at)not-real.peknet.com>
Date: Tue Nov 29 2005 - 15:29:33 GMT
> Hi,
>

Hi David,


> I want to use DC.creator meta tag as a property (metaname) to display in
> the search results page. As part of the display I want to make each of the
> DC.creator values from a document hyperlinked (to the search program) so a
> searcher can find more documents by that creator with one click.
>
> At the moment all the DC.creators are being displayed as one string.

> <meta name="DC.creator" content="Smith A." />
> <meta name="DC.creator" content="Jones B." />
>

You've come across one of the chief confusing things about Swish-e: the
difference between metanames and properties.

A metaname just indicates the \context\ of a word (which tag it is in). A
property is the total \content\ of a tag. Since the 'tag' is the common
denominator, metanames and properties are easily confused.

The short answer to your question is that Swish-e concatenates all
same-named property text into a single property. So in your example above,
the DC.creator property ends up being stored as 'Smith A. Jones B.'.

The longer answer (and 1 possible solution):
append_property() is the C function (in docprop.c) that appends properties
onto one another. There is a comment there:

/* When appending, we separate by a space -- could be a config setting */

that indicates that a single space is used as the concatenation string.
Instead of using a space, you could use another known character (like a |
or something more unique like +|+) and then when retrieving the property,
you could split() it into an array on that concatenation string.

Another solution would be to filter your documents prior to indexing to
add your special character (or string) to the relevant tags. Thus:

 <meta name="DC.creator" content="Smith A." />
 <meta name="DC.creator" content="Jones B." />

would become:

 <meta name="DC.creator" content="Smith A. +|+" />
 <meta name="DC.creator" content="Jones B." />

and you could then do the same split() in your calling Perl code to split
the single property into an array. I do something more like this second
solution because it allows me more flexibility than changing the swish-e
source code and recompiling. (As the C comment in the src indicates, what
would be ideal would be to make the concatenation string a configurable
feature.)


-- 
Peter Karman . http://peknet.com/ . peter(at)not-real.peknet.com
Received on Tue Nov 29 07:29:38 2005