Skip to main content.
home | support | download

Back to List Archive

Re: Making SWISH::API->new() accept a list?

From: Bill Moseley <moseley(at)>
Date: Tue Nov 30 2004 - 19:52:53 GMT
On Tue, Nov 30, 2004 at 11:21:57AM -0800, Lars Kellogg-Stedman wrote:
> Howdy all,
> I've just started working with SWISH::API, and I was startled to find 
> that SWISH::API->new() doesn't actually accept a list of index files.  
> In fact, it accepts a scalar, which is a space seperated list of files.

I would agree.  It was done that way for, eh, historical reasons.
It's possible that was done that way to prevent running a search
before all indexes are opened. 

You could always do this:

   SWISH::API->new( "@list" );

   SWISH::API->new( join ' ', @list );

> Space seperated pathname lists are generally a bad idea...what if a path 
> component contains a space?

We would think you spent too much time on Windows. ;)


   SWISH::API->new( join ' ', map { q["$_"] } @list );

> It would also be a lot more perl-like to accept a list when, you know, 
> we're using a list.


> I haven't worked with the Perl XS stuff before, but I'm looking at 
> coding that up right now.  If I get something working, I'll post it to 
> the list.  I'm assuming that I can replace this:
>   handle = SwishInit( index_file_list );
> With this (pseudocode):
>   handle = SwishNew();
>   FOR EACH file IN index_file_list DO
>     addindexfile(handle, file)

That's a good idea.  The XS could just look for list being passed in.

We were talking about this a week or so ago on the developer's list.
I was suggesting that the index file be a separate object.  So you
might first create a few indexes and then "attach" them to the main
swish object.

  my $index1 = SWISH::API->new_index( 'index.1' );
  my $index2 = SWISH::API->new_index( 'index.2' );

  my $swish = SWISH::API->new;
  $swish->add_index( $index1 );
  $swish->add_index( $index2 );

Again, I'm not clear what might break if a search was run between
adding the two indexes.

In the end, this falls into one of those problem categories that has
not been addressed because it's easy to work around (like the
join/map above).

Bill Moseley

Unsubscribe from or help with the swish-e list:

Help with Swish-e:
Received on Tue Nov 30 11:52:54 2004