Lucene SpellCheck 不索引 2 个字母的单词

bod*_*man 10 java lucene spell-checking

我正在使用 Lucene 进行拼写检查操作。但它不索引 2 个字母的单词。这似乎是 Lucene 拼写检查的常见问题。

这是我的索引方法:

    String fileName = "words.txt";

    Dictionary dictionary = null;
    try {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName)), "UTF-8"));
        dictionary = new PlainTextDictionary(bufferedReader);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } 

    SpellChecker spell = null;
    try {
        Directory directory = FSDirectory.open(spellCheckerPath);
        spell = new SpellChecker(directory);
        spell .setAccuracy(0.5f);
    } catch (IOException e) {
        e.printStackTrace();
    }

    IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_4_10_2, new StandardAnalyzer());
    indexWriterConfig.setOpenMode(OpenMode.CREATE_OR_APPEND);
    try {
        spell.indexDictionary(dictionary, indexWriterConfig, true);
        spell.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

现在,此方法适用于 3 个或更多字母的单词。但是,它不能索引 2 个字母的单词。我读到了停用词。我试图将空的停用词作为参数提供给 StandardAnalyzer;但它没有用。(另外,我试着用Luke搜索,没找到)

我需要使用 4.10.2 版本的 Lucene。我很感激任何帮助。