mirror of https://github.com/apache/lucene.git
SOLR-2173 Suggester should always rebuild Lookup data if Lookup.load fails.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1025781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
19244901b0
commit
9a1ffd44db
|
@ -530,6 +530,8 @@ Bug Fixes
|
||||||
* SOLR-1794: Dataimport of CLOB fields fails when getCharacterStream() is
|
* SOLR-1794: Dataimport of CLOB fields fails when getCharacterStream() is
|
||||||
defined in a superclass. (Gunnar Gauslaa Bergem via rmuir)
|
defined in a superclass. (Gunnar Gauslaa Bergem via rmuir)
|
||||||
|
|
||||||
|
* SOLR-2173 Suggester should always rebuild Lookup data if Lookup.load fails. (ab)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -129,20 +129,10 @@ public class Suggester extends SolrSpellChecker {
|
||||||
if (lookup.load(storeDir)) {
|
if (lookup.load(storeDir)) {
|
||||||
return; // loaded ok
|
return; // loaded ok
|
||||||
}
|
}
|
||||||
|
LOG.debug("load failed, need to build Lookup again");
|
||||||
}
|
}
|
||||||
// dictionary based on the current index may need refreshing
|
// loading was unsuccessful - build it again
|
||||||
if (dictionary instanceof HighFrequencyDictionary) {
|
build(core, searcher);
|
||||||
reader = reader.reopen();
|
|
||||||
dictionary = new HighFrequencyDictionary(reader, field, threshold);
|
|
||||||
try {
|
|
||||||
lookup.build(dictionary);
|
|
||||||
if (storeDir != null) {
|
|
||||||
lookup.store(storeDir);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String query, int numHits) {
|
public void add(String query, int numHits) {
|
||||||
|
|
|
@ -63,6 +63,20 @@ public class SuggesterTest extends SolrTestCaseJ4 {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReload() throws Exception {
|
||||||
|
addDocs();
|
||||||
|
assertU(commit());
|
||||||
|
assertQ(req("qt","/suggest", "q","ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
|
||||||
|
"//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']");
|
||||||
|
assertU(adoc("id", "4",
|
||||||
|
"text", "actually"
|
||||||
|
));
|
||||||
|
assertU(commit());
|
||||||
|
assertQ(req("qt","/suggest", "q","ac", SpellingParams.SPELLCHECK_COUNT, "2", SpellingParams.SPELLCHECK_ONLY_MORE_POPULAR, "true"),
|
||||||
|
"//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='ac']/int[@name='numFound'][.='2']");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private TermFreqIterator getTFIT() {
|
private TermFreqIterator getTFIT() {
|
||||||
final int count = 100000;
|
final int count = 100000;
|
||||||
|
|
Loading…
Reference in New Issue