jGuru
Register Email     Password Forgot your
password?
HOME FAQS FORUMS DOWNLOADS ARTICLES PEERSCOPE LEARN

  Search   jGuru Search Help

Question How do I write my own Analyzer?
Derived from A question posed by Otis Gospodnetic PREMIUM
Topics Tools:Search:Lucene:Analysis
Author Otis Gospodnetic PREMIUM
Created Sep 30, 2002 Modified Nov 10, 2002


Answer
Here is an example:
public class MyAnalyzer extends Analyzer
{
    private static final Analyzer STANDARD = new StandardAnalyzer();

    public TokenStream tokenStream(String field, final Reader reader) 
    {
        // do not tokenize field called 'element'
        if ("element".equals(field))
        {
            return new CharTokenizer(reader)
            {
                protected boolean isTokenChar(char c)
                {
                    return true;
                }
            };
        }
        else
        {
            // use standard analyzer
            return STANDARD.tokenStream(field, reader);
        }
    }
}


Is this item helpful?  yes  no     Previous votes   Yes: 1  No: 4



Comments and alternative answers

Comment on this FAQ entry

There are currently no comments

Ask A Question



 
Related Links

Lucene FAQ

Lucene Forum

Lucene Homepage

Wish List
Features
About jGuru
Contact Us

 



The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers