我有一个Lucene SpellChecker
索引实现,如下所示:
def buildAutoSuggestIndex(path:Path):SpellChecker = {
val config = new IndexWriterConfig(new CustomAnalyzer())
val dictionary = new PlainTextDictionary(path)
val directory = FSDirectory.open(path.getParent)
val spellChecker = new SpellChecker(directory)
val jw = new JaroWinklerDistance()
jw.setThreshold(jaroWinklerThreshold)
spellChecker.setStringDistance(new JaroWinklerDistance())
spellChecker.indexDictionary(dictionary, config, true)
spellChecker
}
我需要更新这些Spellchecker
词典,即重新索引新条目,而无需重新索引整个索引。有没有办法更新SpellChecker
索引?
答案 0 :(得分:1)
$('#example').on( 'search.dt', function (e, settings) {
var api = new $.fn.dataTable.Api( settings );
var query = api.search();
if(query === ''){
$('#example tfoot').show();
} else {
$('#example tfoot').hide();
}
});
var table = $('#example').DataTable();
已经避免在这里重新编制索引:
SpellChecker.indexDictionary(...)
如果该术语已被包含, terms: while ((currentTerm = iter.next()) != null) {
String word = currentTerm.utf8ToString();
int len = word.length();
if (len < 3) {
continue; // too short we bail but "too long" is fine...
}
if (!isEmpty) {
for (TermsEnum te : termsEnums) {
if (te.seekExact(currentTerm)) {
continue terms;
}
}
}
// ok index the word
Document doc = createDocument(word, getMin(len), getMax(len));
writer.addDocument(doc);
将返回seelkExact
,并且未添加具有该术语的n-gram的文档(false
)。