On Wed, 24 Dec 2014, iceout wrote:
I just subscribe the mail list. And I don't know how reply the thread
before. So I have to create a new one.
In lucene 4.4, the method newTermQuery() is defined in class
QueryParserBase, and QueryParser extends QueryParserBase.
In lucene 4.10, the method newTermQuery() is defined in class QueryBuilder,
and class QueryParserBase extends QueryBuilder, and class QueryParser
extends QueryParserBase.
In java, I can simply override newTermQuery() method when extends
QueryParser.
But in pylucene, it didn't work, both 4.4 and 4.10 version.
Is there something wrong?
If you apply the attached patch to a PyLycene 4.10.1 checkout:
(if the attachment disappeared, let me know and I'll send it inline)
$ cd <PyLucene 4.10.1 source directory>
$ patch -Nup0 < patch.newTermQuery.txt
and rebuild PyLucene
$ find . -name 'extensions.jar' | xargs rm
$ make
and run tests
$ make test
you should see that newTermQuery is called when the
test_PythonQueryParser.py
file is run by make test, that this output is emitted:
.CALLING newTermQuery with all:foo
CALLING newTermQuery with all:bar
.
As far as stock 4.10.1 PyLucene is concerned, extended newTermQuery() as
shown by this patch seems to be working as expected.
If you find otherwise, please reply with a patch that applies to PyLucene
4.10.1, that reproduces the problem you're experiencing.
Thanks !
Andi..
--
Best Regards,
iceout
Index: java/org/apache/pylucene/queryparser/classic/PythonQueryParser.java
===================================================================
--- java/org/apache/pylucene/queryparser/classic/PythonQueryParser.java
(revision 1628343)
+++ java/org/apache/pylucene/queryparser/classic/PythonQueryParser.java
(working copy)
@@ -18,6 +18,7 @@
import java.util.List;
import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.index.Term;
import org.apache.lucene.search.Query;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.queryparser.classic.CharStream;
@@ -70,6 +71,8 @@
public native Query getFieldQuery_slop(String field, String queryText,
int slop);
+ public native Query newTermQuery(Term term);
+
public Query getFieldQuery_quoted_super(String field, String queryText,
boolean quoted)
throws ParseException
Index: test/test_PythonQueryParser.py
===================================================================
--- test/test_PythonQueryParser.py (revision 1628343)
+++ test/test_PythonQueryParser.py (working copy)
@@ -42,6 +42,9 @@
class TestQueryParser(BooleanTestMixin, PythonQueryParser):
def getFieldQuery_quoted(_self, field, queryText, quoted):
return super(TestQueryParser,
_self).getFieldQuery_quoted_super(field, queryText, quoted)
+ def newTermQuery(_self, term):
+ print "CALLING newTermQuery with", term
+ return TermQuery(term)
qp = TestQueryParser(Version.LUCENE_CURRENT, 'all',
StandardAnalyzer(Version.LUCENE_CURRENT))