mirror of https://github.com/apache/lucene.git
SOLR-795 -- SpellCheckComponent supports building indices on optimize if configured in solrconfig.xml
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@708653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9c3ab6d75f
commit
5a7f0c6cd9
20
CHANGES.txt
20
CHANGES.txt
|
@ -45,17 +45,17 @@ New Features
|
||||||
|
|
||||||
3. SOLR-658: Allow Solr to load index from arbitrary directory in dataDir
|
3. SOLR-658: Allow Solr to load index from arbitrary directory in dataDir
|
||||||
(Noble Paul, Akshay Ukey via shalin)
|
(Noble Paul, Akshay Ukey via shalin)
|
||||||
|
|
||||||
4. SOLR-793: Add 'commitWithin' argument to the update add command. This behaves
|
4. SOLR-793: Add 'commitWithin' argument to the update add command. This behaves
|
||||||
similar to the global autoCommit maxTime argument except that it is set for
|
similar to the global autoCommit maxTime argument except that it is set for
|
||||||
each request. (ryan)
|
each request. (ryan)
|
||||||
|
|
||||||
5. SOLR-670: Add support for rollbacks in UpdateHandler. This allows user to rollback all changes
|
5. SOLR-670: Add support for rollbacks in UpdateHandler. This allows user to rollback all changes
|
||||||
since the last commit. (Noble Paul, koji via shalin)
|
since the last commit. (Noble Paul, koji via shalin)
|
||||||
|
|
||||||
6. SOLR-813: Adding DoubleMetaphone Filter and Factory. Similar to the PhoneticFilter,
|
6. SOLR-813: Adding DoubleMetaphone Filter and Factory. Similar to the PhoneticFilter,
|
||||||
but this uses DoubleMetaphone specific calls (including alternate encoding)
|
but this uses DoubleMetaphone specific calls (including alternate encoding)
|
||||||
(Todd Feak via ryan)
|
(Todd Feak via ryan)
|
||||||
|
|
||||||
7. SOLR-680: Add StatsComponent. This gets simple statists on matched numeric fields,
|
7. SOLR-680: Add StatsComponent. This gets simple statists on matched numeric fields,
|
||||||
including: min, max, mean, median, stddev. (koji, ryan)
|
including: min, max, mean, median, stddev. (koji, ryan)
|
||||||
|
@ -70,6 +70,8 @@ New Features
|
||||||
10. SOLR-651: Added TermVectorComponent for serving up term vector information, plus IDF.
|
10. SOLR-651: Added TermVectorComponent for serving up term vector information, plus IDF.
|
||||||
See http://wiki.apache.org/solr/TermVectorComponent (gsingers, Vaijanath N. Rao, Noble Paul)
|
See http://wiki.apache.org/solr/TermVectorComponent (gsingers, Vaijanath N. Rao, Noble Paul)
|
||||||
|
|
||||||
|
12. SOLR-795: SpellCheckComponent supports building indices on optimize if configured in solrconfig.xml
|
||||||
|
(Jason Rennie, shalin)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -89,8 +91,6 @@ Bug Fixes
|
||||||
|
|
||||||
4. SOLR-805: DisMax queries are not being cached in QueryResultCache (Todd Feak via koji)
|
4. SOLR-805: DisMax queries are not being cached in QueryResultCache (Todd Feak via koji)
|
||||||
|
|
||||||
5. SOLR-803, SOLR-827: Fix CoreAdminRequest#createCore (Sean Colombo via ryan)
|
|
||||||
|
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -100,13 +100,7 @@ Other Changes
|
||||||
|
|
||||||
3. DumpRequestHandler (/debug/dump): changed 'fieldName' to 'sourceInfo'. (ehatcher)
|
3. DumpRequestHandler (/debug/dump): changed 'fieldName' to 'sourceInfo'. (ehatcher)
|
||||||
|
|
||||||
4. SOLR-657: Replace many deprecated calls with non-deprecated equivalents
|
|
||||||
(Lars Kotthoff via ryan)
|
|
||||||
|
|
||||||
5. SOLR-816: Deprecate access to SolrConfig from IndexSchema. Rather then access
|
|
||||||
SolrConfig from the schema, plugins should get the config from the core. IndexSchema
|
|
||||||
still has access to the ResourceLoader. (ryan)
|
|
||||||
|
|
||||||
Build
|
Build
|
||||||
----------------------
|
----------------------
|
||||||
1. SOLR-776: Added in ability to sign artifacts via Ant for releases (gsingers)
|
1. SOLR-776: Added in ability to sign artifacts via Ant for releases (gsingers)
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.apache.solr.schema.FieldType;
|
||||||
import org.apache.solr.schema.IndexSchema;
|
import org.apache.solr.schema.IndexSchema;
|
||||||
import org.apache.solr.search.SolrIndexSearcher;
|
import org.apache.solr.search.SolrIndexSearcher;
|
||||||
import org.apache.solr.spelling.*;
|
import org.apache.solr.spelling.*;
|
||||||
import org.apache.solr.util.RefCounted;
|
|
||||||
import org.apache.solr.util.plugin.NamedListPluginLoader;
|
import org.apache.solr.util.plugin.NamedListPluginLoader;
|
||||||
import org.apache.solr.util.plugin.SolrCoreAware;
|
import org.apache.solr.util.plugin.SolrCoreAware;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
@ -273,10 +272,12 @@ public class SpellCheckComponent extends SearchComponent implements SolrCoreAwar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Register event listeners for this SpellChecker
|
// Register event listeners for this SpellChecker
|
||||||
core.registerFirstSearcherListener(new SpellCheckerListener(core, checker, true));
|
core.registerFirstSearcherListener(new SpellCheckerListener(core, checker, false, false));
|
||||||
if (Boolean.parseBoolean((String)spellchecker.get("buildOnCommit"))) {
|
boolean buildOnCommit = Boolean.parseBoolean((String) spellchecker.get("buildOnCommit"));
|
||||||
|
boolean buildOnOptimize = Boolean.parseBoolean((String) spellchecker.get("buildOnOptimize"));
|
||||||
|
if (buildOnCommit || buildOnOptimize) {
|
||||||
LOG.info("Registering newSearcher listener for spellchecker: " + checker.getDictionaryName());
|
LOG.info("Registering newSearcher listener for spellchecker: " + checker.getDictionaryName());
|
||||||
core.registerNewSearcherListener(new SpellCheckerListener(core, checker, false));
|
core.registerNewSearcherListener(new SpellCheckerListener(core, checker, buildOnCommit, buildOnOptimize));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Can't load spell checker: " + className);
|
throw new RuntimeException("Can't load spell checker: " + className);
|
||||||
|
@ -316,12 +317,14 @@ public class SpellCheckComponent extends SearchComponent implements SolrCoreAwar
|
||||||
private static class SpellCheckerListener implements SolrEventListener {
|
private static class SpellCheckerListener implements SolrEventListener {
|
||||||
private final SolrCore core;
|
private final SolrCore core;
|
||||||
private final SolrSpellChecker checker;
|
private final SolrSpellChecker checker;
|
||||||
private final boolean firstSearcher;
|
private final boolean buildOnCommit;
|
||||||
|
private final boolean buildOnOptimize;
|
||||||
|
|
||||||
public SpellCheckerListener(SolrCore core, SolrSpellChecker checker, boolean firstSearcher) {
|
public SpellCheckerListener(SolrCore core, SolrSpellChecker checker, boolean buildOnCommit, boolean buildOnOptimize) {
|
||||||
this.core = core;
|
this.core = core;
|
||||||
this.checker = checker;
|
this.checker = checker;
|
||||||
this.firstSearcher = firstSearcher;
|
this.buildOnCommit = buildOnCommit;
|
||||||
|
this.buildOnOptimize = buildOnOptimize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(NamedList args) {
|
public void init(NamedList args) {
|
||||||
|
@ -329,7 +332,8 @@ public class SpellCheckComponent extends SearchComponent implements SolrCoreAwar
|
||||||
|
|
||||||
public void newSearcher(SolrIndexSearcher newSearcher,
|
public void newSearcher(SolrIndexSearcher newSearcher,
|
||||||
SolrIndexSearcher currentSearcher) {
|
SolrIndexSearcher currentSearcher) {
|
||||||
if (firstSearcher) {
|
if (currentSearcher == null) {
|
||||||
|
// firstSearcher event
|
||||||
try {
|
try {
|
||||||
LOG.info("Loading spell index for spellchecker: "
|
LOG.info("Loading spell index for spellchecker: "
|
||||||
+ checker.getDictionaryName());
|
+ checker.getDictionaryName());
|
||||||
|
@ -339,17 +343,29 @@ public class SpellCheckComponent extends SearchComponent implements SolrCoreAwar
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// newSearcher event
|
// newSearcher event
|
||||||
try {
|
if (buildOnCommit) {
|
||||||
LOG.info("Building spell index for spell checker: " + checker.getDictionaryName());
|
buildSpellIndex(newSearcher);
|
||||||
checker.build(core, newSearcher);
|
} else if (buildOnOptimize) {
|
||||||
} catch (Exception e) {
|
if (newSearcher.getReader().isOptimized()) {
|
||||||
log.error(
|
buildSpellIndex(newSearcher);
|
||||||
"Exception in building spell check index for spellchecker: " + checker.getDictionaryName(), e);
|
} else {
|
||||||
|
LOG.info("Index is not optimized therefore skipping building spell check index for: " + checker.getDictionaryName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buildSpellIndex(SolrIndexSearcher newSearcher) {
|
||||||
|
try {
|
||||||
|
LOG.info("Building spell index for spell checker: " + checker.getDictionaryName());
|
||||||
|
checker.build(core, newSearcher);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(
|
||||||
|
"Exception in building spell check index for spellchecker: " + checker.getDictionaryName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void postCommit() {
|
public void postCommit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue