You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Burton-West, Tom" <tb...@umich.edu> on 2010/11/11 19:03:56 UTC

Solr 1.4.1 Analysis console gives error regarding CharTermAttributeImpl that is not in the target

Hello all,

I am using Solr 1.4.1 and a custom filter that worked with a previous version of Solr that used Lucene 2.9.  When I try to use the analysis console I get this error message:

  java.lang.IllegalArgumentException: This AttributeSource contains AttributeImpl of type org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl that is not in the target
(See below for stack trace that shows this is an interaction of the custom "punctuation filter" and the Analysis jsp)

I believe this has to do with this JIRA issue: https://issues.apache.org/jira/browse/LUCENE-2302

I looked at the most recent org.apache.lucene.analysis package document http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/analysis/package.html?view=co  but didn't see a mention of CharTermAttributeImpl

Can someone point me to the documentation or example code that might explain the issue?

Tom Burton-West
Stack trace excerpt:

Caused by: java.lang.IllegalArgumentException: This AttributeSource contains AttributeImpl of type org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl that is not in the target
        at org.apache.lucene.util.AttributeSource.copyTo(AttributeSource.java:493)
        at org.apache.jsp.admin.analysis_jsp$1.incrementToken(org.apache.jsp.admin.analysis_jsp:102)
        at org.apache.solr.analysis.PunctuationFilter.incrementToken(PunctuationFilter.java:40)
        at org.apache.jsp.admin.analysis_jsp.getTokens(org.apache.jsp.admin.analysis_jsp:131)
        at org.apache.jsp.admin.analysis_jsp.doAnalyzer(org.apache.jsp.admin.analysis_jsp:110)
        at org.apache.jsp.admin.analysis_jsp._jspService(org.apache.jsp.admin.analysis_jsp:718)



Re: Solr 1.4.1 Analysis console gives error regarding CharTermAttributeImpl that is not in the target

Posted by Robert Muir <rc...@gmail.com>.
On Thu, Nov 11, 2010 at 1:25 PM, Burton-West, Tom <tb...@umich.edu> wrote:
> I do need to port my filter to lucene 3.x, so is there 3.x documentation about use of CharTermAttributeImpl?
>
> Is this something that needs to be in the TokenStream examples in the 3.0.2 org.apache.lucene.analysis package.html?

No, it is still unreleased, but is in the 3.x branch for what is
scheduled to be the 3.1 release.
So its not relevant to 3.0.2, it does not exist there.

Additionally, even in 3.1 when this is released, your old
TermAttribute code will continue to work transparently. Some
tokenstreams can use CharTermAttribute and some can use TermAttribute
interchangeably so you can upgrade at your leisure...

The examples in 3.1 are changed to the new CharTermAttribute. its
pretty trivial to upgrade if you don't need to take advantage of its
new capabilities, mostly simple stuff like changing .setTermLength()
to .setLength(), etc.


If you want to use the new capabilities, they are that
CharTermAttribute implements CharSequence and Appendable. This means
for example its more easy to integrate with libraries (including java
itself) that support these interfaces.

For example: you can look at PatternReplaceFilter, in its ctor it just
does Matcher matcher = pattern.matcher(charTermAtt).
Then in its incrementToken, it can just call matcher.reset() and
matcher.find() etc directly on the reusable attribute.

Bottom line: with the way it is now, you don't have to change any code
until lucene 4.0 unless you want to, and can keep using TermAttribute
if you are happy with it.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Solr 1.4.1 Analysis console gives error regarding CharTermAttributeImpl that is not in the target

Posted by "Burton-West, Tom" <tb...@umich.edu>.
Ok, I was using a recent unreleased version of Solr/Lucene but looking at the Lucene 3.0.2 docs instead of the nightly build docs.  Found the answer I needed in the nightly build docs.
https://hudson.apache.org/hudson/job/Lucene-trunk/javadoc//core/org/apache/lucene/analysis/package-summary.html

Tom


-----Original Message-----
From: Burton-West, Tom [mailto:tburtonw@umich.edu] 
Sent: Thursday, November 11, 2010 1:26 PM
To: dev@lucene.apache.org
Subject: RE: Solr 1.4.1 Analysis console gives error regarding CharTermAttributeImpl that is not in the target

>> Something here is using lucene 3.x or trunk code, since
>>CharTermAttribute[Impl] only exists in unreleased versions!

Doh!   I forgot to switch my binaries back to Solr 1.4.1 from 3.x.  Thanks for the catch Robert.  The subject line should read: Solr/Lucene 3.x Analysis console gives error regarding CharTermAttributeImpl that is not in the target

I do need to port my filter to lucene 3.x, so is there 3.x documentation about use of CharTermAttributeImpl?

Is this something that needs to be in the TokenStream examples in the 3.0.2 org.apache.lucene.analysis package.html?

Tom

RE: Solr 1.4.1 Analysis console gives error regarding CharTermAttributeImpl that is not in the target

Posted by "Burton-West, Tom" <tb...@umich.edu>.
>> Something here is using lucene 3.x or trunk code, since
>>CharTermAttribute[Impl] only exists in unreleased versions!

Doh!   I forgot to switch my binaries back to Solr 1.4.1 from 3.x.  Thanks for the catch Robert.  The subject line should read: Solr/Lucene 3.x Analysis console gives error regarding CharTermAttributeImpl that is not in the target

I do need to port my filter to lucene 3.x, so is there 3.x documentation about use of CharTermAttributeImpl?

Is this something that needs to be in the TokenStream examples in the 3.0.2 org.apache.lucene.analysis package.html?

Tom

Re: Solr 1.4.1 Analysis console gives error regarding CharTermAttributeImpl that is not in the target

Posted by Robert Muir <rc...@gmail.com>.
On Thu, Nov 11, 2010 at 1:03 PM, Burton-West, Tom <tb...@umich.edu> wrote:
> Hello all,
>
> I am using Solr 1.4.1 and a custom filter that worked with a previous
> version of Solr that used Lucene 2.9.  When I try to use the analysis
> console I get this error message:
>

Are you sure your punctuation filter doesnt use CharTermAttribute?
Something here is using lucene 3.x or trunk code, since
CharTermAttribute[Impl] only exists in unreleased versions!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org