Solr 4.4: StopFilterFactory and enablePositionIncrements

泪湿孤枕 提交于 2019-12-04 03:56:20

You can use proximity searching:

"foo bar"~2

I don't know if this is recommended for usage, but there are still some legacy classes in Lucene 5, such as Lucene43StopFilter.

Unfortunately they seem to have disappeared in Lucene 6...

I found somewhere on the net implementation of RemoveTokenGapsFilterFactory

public final class RemoveTokenGapsFilter extends TokenFilter {

    private final PositionIncrementAttribute posIncrAttribute = addAttribute(PositionIncrementAttribute.class);

    public RemoveTokenGapsFilter(TokenStream input) {
        super(input);
    }

    @Override
    public boolean incrementToken() throws IOException {

        if (input.incrementToken()) {
            posIncrAttribute.setPositionIncrement(1);
            return true;
        }

        return false;
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!