Skip to content

Commit

Permalink
update to 3.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jan 17, 2025
1 parent 854a2ec commit c21f131
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public boolean accept(Resource pathname) {
private Log log;

private final CFMLEngine engine;

private IndexWriterConfig config;
private static final SerializableObject token = new SerializableObject();

/**
Expand Down Expand Up @@ -213,7 +215,7 @@ private void indexSpellCheck(String id) throws SearchException {
Dictionary dictionary = new LuceneDictionary(reader, "contents");

SpellChecker spellChecker = new SpellChecker(spellDir);
spellChecker.indexDictionary(dictionary);
spellChecker.indexDictionary(dictionary, _getConfig(), true);

} catch (Exception e) {
throw new SearchException(e);
Expand Down Expand Up @@ -793,6 +795,14 @@ private Resource _getIndexDirectory(String id, boolean createIfNotExists) {
return indexDir;
}

private IndexWriterConfig _getConfig() throws SearchException {
if (config == null) {
config = new IndexWriterConfig(CommonUtil.VERSION, SearchUtil.getAnalyzer(getLanguage()));

}
return config;
}

/**
* get writer to id
*
Expand All @@ -805,7 +815,6 @@ private Resource _getIndexDirectory(String id, boolean createIfNotExists) {
*/
private IndexWriter _getWriter(String id, boolean create) throws SearchException, IOException, PageException {
Resource dir = _getIndexDirectory(id, true);
IndexWriterConfig config = new IndexWriterConfig(CommonUtil.VERSION, SearchUtil.getAnalyzer(getLanguage()));

// Set create/append mode
if (create) {
Expand All @@ -814,7 +823,7 @@ private IndexWriter _getWriter(String id, boolean create) throws SearchException
config.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
}

return new IndexWriter(FSDirectory.open(engine.getCastUtil().toFile(dir)), config);
return new IndexWriter(FSDirectory.open(engine.getCastUtil().toFile(dir)), _getConfig());
}

private IndexReader _getReader(String id, boolean absolute) throws IOException, PageException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.highlight.Highlighter;
import org.apache.lucene.search.highlight.InvalidTokenOffsetsException;
import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.SimpleHTMLFormatter;

Expand All @@ -15,7 +16,7 @@
public class _Highlight {

public static String createContextSummary(Object highlighter, Analyzer analyzer, String text, int maxNumFragments,
String defaultValue) throws IOException {
String defaultValue) throws IOException, InvalidTokenOffsetsException {
// try {
if (!(highlighter instanceof Highlighter) || analyzer == null || Util.isEmpty(text))
return defaultValue;
Expand Down

0 comments on commit c21f131

Please sign in to comment.