set_max_expansion in perl-bindings?

Olly Betts olly at survex.com
Mon Nov 16 18:05:22 GMT 2020


On Mon, Nov 16, 2020 at 05:31:17PM +0100, Adam Sjøgren wrote:
> I've just noticed that set_max_wildcard_expansion() has been removed in
> favour of set_max_expansion() in Xapian.

Yes, though it's only actually been removed from git master.

> Has the new method been added to the Perl-bindings?

It's not wrapped for the older hand-coded Search::Xapian.  I've not been
actively updating that for such API changes because it's quite a lot of
manual work, though I'm happy to take clean patches.

The newer SWIG-based bindings wrap it, and as of 1.4.16 they're no
longer "experimental".  They aim to be compatible with Search::Xapian
to a large degree, but a few things aren't - there's a list of these
(or at least those we know about) in the POD docs.  Probably the most
likely to affect people is that we no longer overload stringification
and integer conversion.  For stringification this is forced on us by
a current limitation of SWIG, but in hindsight overloading these to
call entirely different methods for different classes is quite
confusing.

> We have some old Perl code that uses set_max_wildcard_expansion(), and I
> have a test of too large expansion that now returns "something terrible
> happened" instead of"Exception: Wildcard ... expands too much (exceeding
> N)", so I'm looking to migrate.

I had a quick look and I think this is because Search::Xapian is still
maintained on the 1.2 branch, and uses a list of the C++ exceptions
from xapian-core 1.2.x.  This exception is thrown as WildcardError,
which was added since 1.2.x, so it isn't identified specifically and
the fallback message "something terrible happened" is used instead.

So I think we could just copy over the latest list of exceptions to
address that.  But for a short term workaround your testcase can
probably just accept the "something terrible happened" as meaning the
exception was triggered.

Cheers,
    Olly



More information about the Xapian-discuss mailing list