You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by nitishgarg <ni...@gmail.com> on 2010/12/29 14:12:21 UTC

Custom Analyzer

I have written a custom analyzer for Marathi Language on the lines of French
Analyzer present in Lucene tweaking the stemming part. For compilation I put
the three classes MarathiAnalyzer, MarathiStemFilter and MarathiStemmer in
the MarathiAnalyzer class only (otherwise I was receiving errors that the
marathiStemmer class is unavailable in MarathiStemFilter, dunno why?). 

After compilation I regenerated the lucene-analyzers-2.9.1.jar file and put
it in the lib folder. 
But when I edit my schema.xml to use MarathiAnlyzer by writing <analyzer
type="index" class="org.apache.lucene.analysis.mr.MarathiAnalyzer">, and
when I run the start.jar file Solr throws me classNotFoundException as: 
java.lang.ClassNotFoundException:
org.apache.lucene.analysis.mr.MarathiAnalyzer 

I tried using the FrenchAnalyzer using the same method and I was successful
in doing that, but unsuccessful when I do the same for MarathiAnalyzer. 

Can anybody tell where I am mistaking?
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Custom-Analyzer-tp2162710p2162710.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Custom Analyzer

Posted by Erick Erickson <er...@gmail.com>.
Well, if that's what's in your class, this won't work:
<analyzer
type="index" class="org.apache.lucene.analysis.mr.MarathiAnalyzer">

because it's looking for "org.apache....". You can try just
class="MarathiAnalyzer"

So I'm not sure removing the package statement is really what you want here.

So now I'm wondering if you really put the jar file in the right place, is
it possible
that that's the problem?

Best
Erick

On Thu, Dec 30, 2010 at 8:04 AM, nitishgarg <ni...@gmail.com>wrote:

>
> My actual class files present in the jar file are:
> MarathiAnalyzer.class
> MarathiStemFilter.class
> MarathiStemmer.class
> MarathiAnayzer$1.class
> MarathiAnalyzer$SavedStreams.class
>
> Please tell what else do I need to specify about my problem?
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Custom-Analyzer-tp2162710p2167456.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Custom Analyzer

Posted by nitishgarg <ni...@gmail.com>.
My actual class files present in the jar file are:
MarathiAnalyzer.class
MarathiStemFilter.class
MarathiStemmer.class
MarathiAnayzer$1.class
MarathiAnalyzer$SavedStreams.class

Please tell what else do I need to specify about my problem?
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Custom-Analyzer-tp2162710p2167456.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Custom Analyzer

Posted by Erick Erickson <er...@gmail.com>.
What does jar -tf "your jar file here" show you the actual classes in your
jar are?

You're still saying "it doesn't work", without providing details that let us
help.
Imagine we're asking you for help. Does your message give enough info to
suggest much?

Best
Erick

On Wed, Dec 29, 2010 at 11:51 PM, nitishgarg <ni...@gmail.com>wrote:

>
> Thanks for replying Erick!
> I executed this query jar -tf jarfile.jar and my classes were indeed there.
> Regarding the package I had this line written in my java file:
> package org.apache.lucene.analysis.mr
> I removed this line but still it was not working.
> Then I tried creating a small project (marathi.jar, containing the class
> files) and place it in the lib folder, I even set the CLASSPATH to the jar
> file, but still Solr is throwing me a ClassNotFoundException.
> Please help me out!
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Custom-Analyzer-tp2162710p2166185.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Custom Analyzer

Posted by nitishgarg <ni...@gmail.com>.
Thanks for replying Erick!
I executed this query jar -tf jarfile.jar and my classes were indeed there.
Regarding the package I had this line written in my java file:
package org.apache.lucene.analysis.mr
I removed this line but still it was not working.
Then I tried creating a small project (marathi.jar, containing the class
files) and place it in the lib folder, I even set the CLASSPATH to the jar
file, but still Solr is throwing me a ClassNotFoundException.
Please help me out!
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Custom-Analyzer-tp2162710p2166185.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Custom Analyzer

Posted by Erick Erickson <er...@gmail.com>.
Your problem is probably a classpath issue, but that's like saying
"something's not right", there can be many reasons the classloader
can't find your class.

Look in your jar files to insure that you have what you think is in there,
you can
use 'jar -tf jarfile.jar' to see a list of classes in the file. You may not
have packaged
your classes correctly (i.e. is there "package" directive, something like:
package org.apache.solr.analysis; in your source)?

You shouldn't have to regenerate the analysis jar. Simply create a small
project
that has your files in it, compile that into a jar and drop the jar into
"the right
place" in your Solr hierarchy (see solrconfig.xml, the <lib> directives)
and
you should be fine.

If none of that helps, can you tell us what you've tried?

Best
Erick


On Wed, Dec 29, 2010 at 8:12 AM, nitishgarg <ni...@gmail.com>wrote:

>
> I have written a custom analyzer for Marathi Language on the lines of
> French
> Analyzer present in Lucene tweaking the stemming part. For compilation I
> put
> the three classes MarathiAnalyzer, MarathiStemFilter and MarathiStemmer in
> the MarathiAnalyzer class only (otherwise I was receiving errors that the
> marathiStemmer class is unavailable in MarathiStemFilter, dunno why?).
>
> After compilation I regenerated the lucene-analyzers-2.9.1.jar file and put
> it in the lib folder.
> But when I edit my schema.xml to use MarathiAnlyzer by writing <analyzer
> type="index" class="org.apache.lucene.analysis.mr.MarathiAnalyzer">, and
> when I run the start.jar file Solr throws me classNotFoundException as:
> java.lang.ClassNotFoundException:
> org.apache.lucene.analysis.mr.MarathiAnalyzer
>
> I tried using the FrenchAnalyzer using the same method and I was successful
> in doing that, but unsuccessful when I do the same for MarathiAnalyzer.
>
> Can anybody tell where I am mistaking?
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Custom-Analyzer-tp2162710p2162710.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>