I have added Java wrapper for Searcher class (see attach) and compiled
pylucene 2.4.1 against Python 2.5.4 (debian Linux 2.6.30-2-amd64)

When I try following program

#!/usr/local/bin/python

from lucene import *
class MySearcher(PythonSearcher):
    def __init__(self):
        super(MySearcher, self).__init__()
if __name__=='__main__':
    initVM(CLASSPATH)
    s = MySearcher()
    parallel = ParallelMultiSearcher([s])

 I got this message:

Traceback (most recent call last):
  File "./remote.py", line 13, in <module>
    parallel = ParallelMultiSearcher([s])
lucene.InvalidArgsError: (<type 'ParallelMultiSearcher'>, '__init__',
([<MySearcher: org.apache.pylucene.search.pythonsearc...@19c247a0>],))

What's wrong with my brain? :-)
/* ====================================================================
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * ====================================================================
 */

package org.apache.pylucene.search;

import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.HitCollector;
import org.apache.lucene.search.RemoteSearchable;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.search.Weight;
import org.apache.lucene.index.Term;
import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.document.Document;
import java.util.Collection;

public class PythonSearcher extends Searcher {

    private long pythonObject;

    public PythonSearcher()
    {
    }

    public void pythonExtension(long pythonObject)
    {
        this.pythonObject = pythonObject;
    }
    public long pythonExtension()
    {
        return this.pythonObject;
    }

    public void finalize()
        throws Throwable
    {
        pythonDecRef();
    }

    public native void pythonDecRef();
    public native void close();
    public native Document doc(int i);
    public native Document doc(int i, FieldSelector fieldSelector);
    public native int docFreq(Term term);
    public native int[] docFreqs(Term[] terms);
    public native Explanation explain(Query query, int doc);
    public native Explanation explain(Weight weight, int doc);
    public native int maxDoc();
    public native Query rewrite(Query original);
    public native void search(Query query, Filter filter, HitCollector results);
    public native TopDocs search(Query query, Filter filter, int n);
    public native TopFieldDocs search(Query query, Filter filter, int n, Sort sort);

    public native void search(Weight weight, Filter filter, HitCollector results);
    public native TopDocs search(Weight weight, Filter filter, int n);
    public native TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort);

    // public int[] docFreqs(Collection terms)
    // {
    //     return docFreqs(terms);
    // }
}

Reply via email to