Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7565303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:07:15+00:00 2026-05-30T14:07:15+00:00

I have been trying to implement a custom analyzer in Lucene. I think I

  • 0

I have been trying to implement a custom analyzer in Lucene. I think I am really close to finishing but I face two strange issues.

First, my filter works as expected for every term in the tokenstream except the last one. (Though I am trying to handle it).

Second, I wouldn’t have a problem using that TokenFilter (even missing the last term). But although the indexing is working perfectly (checked the resulting index with Luke), when I try to use my analyzer to parse user queries = the resulting Query is blank(!) Could this be due to the missing term?

I have posted the incrementToken() method of filter below. Any help would be really welcome. Thank you in advance.

P.S. I now that in terms of contribution this question is not good, but i could not find something specific elsewhere.

public boolean incrementToken() throws IOException {
    if (!input.incrementToken()) {
        if (previousTokenFlag) {
            tempPreviousToken.attSource.copyTo(this);
            previousTokenFlag = false;
            this.incrementToken();
            return false;
        } else {
            return false;
        }
    }
    if (previousTokenFlag) {
        if (CheckIfMainName(this.termAtt.term())) {
            if (CheckIfMainName(tempPreviousToken.termAtt.term())) {
                termAtt.setTermBuffer(tempPreviousToken.termAtt.term() + 
                       TOKEN_SEPARATOR + this.termAtt.term());
                this.setPreviousTokenFlag(false);
                return true;
            } else {
                tempHelpingToken = new TempToken(this.input.cloneAttributes());
            }
            tempPreviousToken.attSource.copyTo(this);
            tempHelpingToken.attSource.copyTo(tempPreviousToken.attSource);
            return true;
        } else {
            if (CheckIfMainName(tempPreviousToken.termAtt.term())) {
                tempHelpingToken = new TempToken(this.input.cloneAttributes());
                tempPreviousToken.attSource.copyTo(this);
                tempHelpingToken.attSource.copyTo(tempPreviousToken.attSource);
                tempHelpingToken.attSource.clearAttributes();
                return true;
            } else {
                tempHelpingToken = new TempToken(this.input.cloneAttributes());
                tempPreviousToken.attSource.copyTo(this);
                tempHelpingToken.attSource.copyTo(tempPreviousToken.attSource);
                tempHelpingToken.attSource.clearAttributes();
                return true;
            }
        }
    } else {
        tempPreviousToken = new TempToken(this.input.cloneAttributes());
        tempPreviousToken.termAtt.setTermBuffer(this.termAtt.term());
        this.setPreviousTokenFlag(true);
        this.incrementToken();
        return true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:07:17+00:00Added an answer on May 30, 2026 at 2:07 pm

    I am not sure what you are trying to do, but the first lines of you filter look wrong:

            tempPreviousToken.attSource.copyTo(this);
            previousTokenFlag = false;
            this.incrementToken();
            return false;
    

    First, you copy your tempPreviousToken to the current token (tempPreviousToken.attSource.copyTo(this)), and then you always return false, giving no chance to the current token to be ever used. You should either return false directly, or return true/false depending on the token you tried to copy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys, I have been trying to implement the DSUM function but failed to
I have been trying to implement remote debugging in two different scenarios both without
I'm trying to implement PayPal on a completely custom shopping cart and have been
Im trying to implement an Observer/Observable pattern on an EC2 instance. I have been
I have been trying to understand the way ActionScript's events are implemented, but I'm
I have been trying to implement a CheckBox Node Tree, where the parent nodes
I have been trying to implement hash-tables using uthash.h, following the (excellent) documentation I
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to implement the Facebook Feed Dialog as follows <a href=http://www.facebook.com/dialog/feed?app_id=12345678&redirect_uri=http://example.com&link=http://example.com&message=Hi+wassup!>
Hi I have been trying to implement auto complete in my site from 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.