Discussion:
[jira] [Created] (PYLUCENE-33) Cannot override newTermQuery method of class QueryParser
iceout (JIRA)
2014-12-23 10:31:13 UTC
Permalink
iceout created PYLUCENE-33:
------------------------------

Summary: Cannot override newTermQuery method of class QueryParser
Key: PYLUCENE-33
URL: https://issues.apache.org/jira/browse/PYLUCENE-33
Project: PyLucene
Issue Type: Bug
Environment: ubuntu 12.04, python 2.7
Reporter: iceout


I want to override the newTermQuery method of class QueryParser.

First, I add the following code in org/apache/pylucene/queryparser/classic/PythonQueryParser.java.

protected native Query newTermQuery(Term term);

But it said:

lucene.JavaError: org.apache.jcc.PythonException:java.lang.UnsatisfiedLinkError: org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery

Then I changed the code:

public native Query newTermQuery(Term term);

But there still is a Exception:

lucene.JavaError: org.apache.jcc.PythonException: org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__', (<Term: body:fox>, <type 'AveragePayloadFunction'>))

My python is:

class PayloadQueryParser(PythonQueryParser):

def __init__(self, matchVersion, f, a):
super(PayloadQueryParser, self).__init__(matchVersion, f, a)

def getFieldQuery_quoted(self, field, queryText, quoted):
return super(PayloadQueryParser, self).getFieldQuery_quoted_super(field, queryText, quoted)

def newTermQuery(self, term):
return PayloadTermQuery(term, AveragePayloadFunction)





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Andi Vajda (JIRA)
2014-12-24 01:44:14 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14257809#comment-14257809 ]

Andi Vajda commented on PYLUCENE-33:
------------------------------------

Please, see comments on pylucene-***@lucene.apache.org mailing list.
For questions, please contact the list instead of filing a bug.
Post by iceout (JIRA)
Cannot override newTermQuery method of class QueryParser
--------------------------------------------------------
Key: PYLUCENE-33
URL: https://issues.apache.org/jira/browse/PYLUCENE-33
Project: PyLucene
Issue Type: Bug
Environment: ubuntu 12.04, python 2.7
Reporter: iceout
I want to override the newTermQuery method of class QueryParser.
First, I add the following code in org/apache/pylucene/queryparser/classic/PythonQueryParser.java.
protected native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException:java.lang.UnsatisfiedLinkError: org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery
public native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException: org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__', (<Term: body:fox>, <type 'AveragePayloadFunction'>))
super(PayloadQueryParser, self).__init__(matchVersion, f, a)
return super(PayloadQueryParser, self).getFieldQuery_quoted_super(field, queryText, quoted)
return PayloadTermQuery(term, AveragePayloadFunction)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Andi Vajda
2014-12-24 01:45:09 UTC
Permalink
Post by iceout (JIRA)
I want to override the newTermQuery method of class QueryParser.
There is newTermQuery() method in class QueryParser in Lucene 4.10.x.
Please, specify which version you're verify there is such a method to
override in the classic.QueryParser class.

Andi..
Post by iceout (JIRA)
First, I add the following code in org/apache/pylucene/queryparser/classic/PythonQueryParser.java.
protected native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException:java.lang.UnsatisfiedLinkError: org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery
public native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException: org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__', (<Term: body:fox>, <type 'AveragePayloadFunction'>))
super(PayloadQueryParser, self).__init__(matchVersion, f, a)
return super(PayloadQueryParser, self).getFieldQuery_quoted_super(field, queryText, quoted)
return PayloadTermQuery(term, AveragePayloadFunction)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Andi Vajda
2014-12-24 01:46:00 UTC
Permalink
Post by Andi Vajda
Post by iceout (JIRA)
I want to override the newTermQuery method of class QueryParser.
There is newTermQuery() method in class QueryParser in Lucene 4.10.x.
Sorry, I meant to say that there is _no_ newTermQuery() method on that
class.

Andi..
Post by Andi Vajda
Please, specify which version you're verify there is such a method to
override in the classic.QueryParser class.
Andi..
Post by iceout (JIRA)
First, I add the following code in
org/apache/pylucene/queryparser/classic/PythonQueryParser.java.
protected native Query newTermQuery(Term term);
org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery
public native Query newTermQuery(Term term);
org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__',
(<Term: body:fox>, <type 'AveragePayloadFunction'>))
super(PayloadQueryParser, self).__init__(matchVersion, f, a)
return super(PayloadQueryParser,
self).getFieldQuery_quoted_super(field, queryText, quoted)
return PayloadTermQuery(term, AveragePayloadFunction)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
iceout (JIRA)
2014-12-24 02:03:15 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14257828#comment-14257828 ]

iceout commented on PYLUCENE-33:
--------------------------------

OK. Other methods work fine. So I think maybe it's a bug. Sorry.
Post by iceout (JIRA)
Cannot override newTermQuery method of class QueryParser
--------------------------------------------------------
Key: PYLUCENE-33
URL: https://issues.apache.org/jira/browse/PYLUCENE-33
Project: PyLucene
Issue Type: Bug
Environment: ubuntu 12.04, python 2.7
Reporter: iceout
I want to override the newTermQuery method of class QueryParser.
First, I add the following code in org/apache/pylucene/queryparser/classic/PythonQueryParser.java.
protected native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException:java.lang.UnsatisfiedLinkError: org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery
public native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException: org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__', (<Term: body:fox>, <type 'AveragePayloadFunction'>))
super(PayloadQueryParser, self).__init__(matchVersion, f, a)
return super(PayloadQueryParser, self).getFieldQuery_quoted_super(field, queryText, quoted)
return PayloadTermQuery(term, AveragePayloadFunction)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
iceout
2014-12-24 03:38:17 UTC
Permalink
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?
--
Best Regards,
iceout
Andi Vajda
2014-12-24 04:01:22 UTC
Permalink
Post by iceout
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..
Post by iceout
--
Best Regards,
iceout
iceout
2014-12-24 10:39:21 UTC
Permalink
It works well.
Thanks.
Post by iceout
I just subscribe the mail list. And I don't know how reply the thread
Post by iceout
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 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
.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..
Post by iceout
--
Best Regards,
iceout
--
Best Regards,
iceout
Andi Vajda (JIRA)
2014-12-24 17:58:13 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-33?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Vajda updated PYLUCENE-33:
-------------------------------
Attachment: patch.newTermQuery.txt

This patch, when applied against stock 4.10.1, shows that this works just fine and that there is no bug.
Post by iceout (JIRA)
Cannot override newTermQuery method of class QueryParser
--------------------------------------------------------
Key: PYLUCENE-33
URL: https://issues.apache.org/jira/browse/PYLUCENE-33
Project: PyLucene
Issue Type: Bug
Environment: ubuntu 12.04, python 2.7
Reporter: iceout
Attachments: patch.newTermQuery.txt
I want to override the newTermQuery method of class QueryParser.
First, I add the following code in org/apache/pylucene/queryparser/classic/PythonQueryParser.java.
protected native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException:java.lang.UnsatisfiedLinkError: org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery
public native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException: org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__', (<Term: body:fox>, <type 'AveragePayloadFunction'>))
super(PayloadQueryParser, self).__init__(matchVersion, f, a)
return super(PayloadQueryParser, self).getFieldQuery_quoted_super(field, queryText, quoted)
return PayloadTermQuery(term, AveragePayloadFunction)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Andi Vajda (JIRA)
2014-12-24 17:59:13 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-33?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Vajda resolved PYLUCENE-33.
--------------------------------
Resolution: Not a Problem

works fine, see patch.
Post by iceout (JIRA)
Cannot override newTermQuery method of class QueryParser
--------------------------------------------------------
Key: PYLUCENE-33
URL: https://issues.apache.org/jira/browse/PYLUCENE-33
Project: PyLucene
Issue Type: Bug
Environment: ubuntu 12.04, python 2.7
Reporter: iceout
Attachments: patch.newTermQuery.txt
I want to override the newTermQuery method of class QueryParser.
First, I add the following code in org/apache/pylucene/queryparser/classic/PythonQueryParser.java.
protected native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException:java.lang.UnsatisfiedLinkError: org.apache.pylucene.queryparser.classic.PythonQueryParser.newTermQuery
public native Query newTermQuery(Term term);
lucene.JavaError: org.apache.jcc.PythonException: org.apache.jcc.PythonException: (<type 'PayloadTermQuery'>, '__init__', (<Term: body:fox>, <type 'AveragePayloadFunction'>))
super(PayloadQueryParser, self).__init__(matchVersion, f, a)
return super(PayloadQueryParser, self).getFieldQuery_quoted_super(field, queryText, quoted)
return PayloadTermQuery(term, AveragePayloadFunction)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...