[Xapian-discuss] Python bindings

Olly Betts olly at survex.com
Fri Jun 17 23:39:48 BST 2005


On Thu, Jun 16, 2005 at 10:35:17AM -0300, Christiano Anderson wrote:
> I can index some data using simpleindex, but when I try to search, I got
> the following python error:
> 
> NotImplementedError: No matching function for overloaded 'new_Query'

I quickly narrowed the breakage down to between 0.8.5.1 and 0.9.0, and
(after a lot of recompiling different versions) to this change:

Mon Mar 21 09:37:45 GMT 2005  James Aylett  <james at tartarus.org>

        * xapian.i: updated SWIG-based bindings to latest API

        * python/extra.i: more Python-style iterators

        * tcl8/docs/.cvsignore, tcl8/docs/examples/.cvsignore: ignore
          autogenerated Makefile.in, Makefile

Unfortunately, that's quite a big change.  The tcl8 stuff is clearly
irrelevant (it's not even build related).  But after a bit of prodding
it seems to be a problem in xapian.i:

@@ -669,13 +678,14 @@
         %extend {
            /** Constructs a query from a vector of terms merged with the specified operator */
            Query(Query::op op,
-                 const std::vector<std::string>* subqs,
-                 termpos window = 0) {
-                   Xapian::Query * query=new Xapian::Query(op, subqs->begin(),subqs->end());
-                   if (window) query->set_window(window);
+                 std::vector<std::string>* subqs,
+                 termpos parameter = 0) {
+                   Xapian::Query * query=new Xapian::Query(op, subqs->begin(),subqs->end(), parameter);
                    return query;
            }
        }
+       /** Apply the specified operator to a single Xapian::Query object. */
+       Query(Query::op op_, Xapian::Query q);
 #endif

        /** Constructs a new empty query object */

I wondered at the removal of "const", so I tried adding it back in.  SWIG
moans that it can't find typemap entries (or something):

./../xapian.i:685: Warning(467): Overloaded Xapian::Query(Xapian::Query::op op,std::vector<std::string > const *subqs) not supported (no type checking rule for 'std::vector<std::string > const *').
./../xapian.i:685: Warning(467): Overloaded Xapian::Query(Xapian::Query::op op,std::vector<std::string > const *subqs,Xapian::termpos parameter=0) not supported (no type checking rule for 'std::vector<std::string > const *').

*BUT* the bindings do compile and simplesearch.py appears to work and build
queries as it should!  Yet if I "#ifndef SWIGPYTHON" out the %extend block,
it doesn't work.

James: you made this change - any idea what's going on here?

Incidentally, if you want to do much experimenting with xapian.i, etc then edit
CXXFLAGS in the generated python/Makefile to remove "-O2".  That knocks minutes
off the compile time!

Cheers,
    Olly



More information about the Xapian-discuss mailing list