我正在尝试实现一个solr过滤器,我需要如何从jvm环境运行此过滤器

时间:2014-11-27 04:28:13

标签: solr filter lucene

除了创建类并在solr上运行之外,还有什么方法可以运行和调试我们的代码。我想了解这些类的控制流可以任何一个帮助 包org.apache.lucene.analysis;

public final class MyPathHierarchyFilter extends TokenFilter {     public MyPathHierarchyFilter(Version matchVersion,TokenStream input)     {         超级(输入);         tokenCount = 0;     }

private int tokenCount=0;
public final boolean incrementToken() throws IOException
{
    if(Flag_Tokens_are_read)
    {
        String buffer="";
        if((loop++)!=tokenCount-1)
        {
            for(int k=loop;k<tokenCount;)
            {
                buffer = buffer+tokensArray.get(k).toString();
                k++;
                if(k<tokenCount)
                        buffer=buffer+" ";
                else
                {
                    /*if(Flag_First_Time_total_length)
                    {   startOffset=0;
                        endOffset=17;//buffer.length();
                        Flag_First_Time_total_length=false;
                    }
                    else
                    {
                        int length = buffer.length()-1;
                        startOffset=10;//endOffset-length;
                        endOffset=17;
                    }*/
                    char[] newBuffer = buffer.toCharArray();

                    this.termAtt.copyBuffer(newBuffer, 0, newBuffer.length);
                    //offsetAtt.setOffset(startOffset, endOffset);
                    //posIncAttr.setPositionIncrement(1);
                    return true;
                }
            }
        }
        return false;
    }

    if (input.incrementToken()) 
    {
        String token = termAtt.toString();
        tokensArray.add(token); 

        return incrementToken();

    }
    else
    {   if(Flag_First_Time)
        {
            tokenCount=tokensArray.size();
            Flag_Tokens_are_read=true;
            loop=-1;
            Flag_First_Time = false;
            return incrementToken();
        }
        else
        {
            return false;
        }
    }

}

}

0 个答案:

没有答案