Skip to main content.
home | support | download

Back to List Archive

Re: Question about swish C library

From: Bill Moseley <moseley(at)>
Date: Mon Feb 18 2002 - 08:06:32 GMT
At 11:21 PM 02/17/02 -0800, Cristiano Corsani wrote:
>getResultPropValue(swish_handle, my_result, a-string_with_property_name, 0);
>and it works! Not using
>  metaIDs = result->indexf->propIDToDisplay;
>  for( i=0; i < numPropertiesToDisplay; i++ )
>  {
>      if ( !(pv = getResultPropValue( sw, result, NULL, metaIDs[i])) )
>      {
>          XPUSHs(&PL_sv_undef);
>          continue;
>      }
>as in .xs file. It doesn't work in my C project.

It Should work the same.

>Anothe little things: it seems that you have to put the list of the
>properties you want to display in
>SwishSearch(swish_handle, words, structure, properties, sortspec);
>but it works if I put properties = "" and ask what I want with
>getResultPropValue. Can someone explain me it?

You can also use NULL instead of the empty string.

I'm not 100% sure, but there's two ways to display properties with the
command line swish-e.  You can say:

         swish-e -w foo -p prop1 prop2 prop3

or you can define the format:

         swish-e -w foo -x '<swishrank> <prop1> <prop2> <prop3>\n'

I believe the library SwishSearch was created before -x was added to swish,
so it was designed to be just like -p.  It's also likely that
getResultPropValue() was written after the library was created.

The -p method stores the properties as a list of ID numbers that will be
displayed later.  So in the xs code is simply fetching those ID numbers and
then requesting the file's properties by ID number (instead of by name).

If you look at SwishNext in SWISHE.xs you will notice that it fetches a lot
of properties by default.  Again, this was probably designed to work just
like running swish from the command line.  But if you are not using all
those properties then it's a (tiny!) amount of wasted work fetching those

The SWISHE.xs file is only an interface between the C library and Perl.  As
you can see, you can just call the almost any public function you like in
the library.  And you can also see that not every function  is documented
in the C library API.  In fact, very little is documented in the
SWISH-LIBRARY page.  It's on the todo list...

>Does exist some new release of C library?

Don't get confused about the library;  it is just swish.  There's not
separate C library code.  To build the swish-e binary program the file
swish.c is compiled and linked with the swish library.  So the library is
the same code that's in the swish-e program.

Does that help?
Bill Moseley
Received on Mon Feb 18 08:06:51 2002