You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by sh...@apache.org on 2008/10/28 20:59:46 UTC
svn commit: r708653 - in /lucene/solr/trunk: CHANGES.txt
src/java/org/apache/solr/handler/component/SpellCheckComponent.java
Author: shalin
Date: Tue Oct 28 12:59:44 2008
New Revision: 708653
URL: http://svn.apache.org/viewvc?rev=708653&view=rev
Log:
SOLR-795 -- SpellCheckComponent supports building indices on optimize if configured in solrconfig.xml
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=708653&r1=708652&r2=708653&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Tue Oct 28 12:59:44 2008
@@ -45,17 +45,17 @@
3. SOLR-658: Allow Solr to load index from arbitrary directory in dataDir
(Noble Paul, Akshay Ukey via shalin)
-
+
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)
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)
-
- 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)
- (Todd Feak via ryan)
+ (Todd Feak via ryan)
7. SOLR-680: Add StatsComponent. This gets simple statists on matched numeric fields,
including: min, max, mean, median, stddev. (koji, ryan)
@@ -70,6 +70,8 @@
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)
+12. SOLR-795: SpellCheckComponent supports building indices on optimize if configured in solrconfig.xml
+ (Jason Rennie, shalin)
Optimizations
----------------------
@@ -89,8 +91,6 @@
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
----------------------
@@ -100,13 +100,7 @@
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
----------------------
1. SOLR-776: Added in ability to sign artifacts via Ant for releases (gsingers)
Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/component/SpellCheckComponent.java?rev=708653&r1=708652&r2=708653&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/component/SpellCheckComponent.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/component/SpellCheckComponent.java Tue Oct 28 12:59:44 2008
@@ -51,7 +51,6 @@
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.spelling.*;
-import org.apache.solr.util.RefCounted;
import org.apache.solr.util.plugin.NamedListPluginLoader;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.w3c.dom.NodeList;
@@ -273,10 +272,12 @@
}
}
// Register event listeners for this SpellChecker
- core.registerFirstSearcherListener(new SpellCheckerListener(core, checker, true));
- if (Boolean.parseBoolean((String)spellchecker.get("buildOnCommit"))) {
+ core.registerFirstSearcherListener(new SpellCheckerListener(core, checker, false, false));
+ 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());
- core.registerNewSearcherListener(new SpellCheckerListener(core, checker, false));
+ core.registerNewSearcherListener(new SpellCheckerListener(core, checker, buildOnCommit, buildOnOptimize));
}
} else {
throw new RuntimeException("Can't load spell checker: " + className);
@@ -316,12 +317,14 @@
private static class SpellCheckerListener implements SolrEventListener {
private final SolrCore core;
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.checker = checker;
- this.firstSearcher = firstSearcher;
+ this.buildOnCommit = buildOnCommit;
+ this.buildOnOptimize = buildOnOptimize;
}
public void init(NamedList args) {
@@ -329,7 +332,8 @@
public void newSearcher(SolrIndexSearcher newSearcher,
SolrIndexSearcher currentSearcher) {
- if (firstSearcher) {
+ if (currentSearcher == null) {
+ // firstSearcher event
try {
LOG.info("Loading spell index for spellchecker: "
+ checker.getDictionaryName());
@@ -339,17 +343,29 @@
}
} else {
// newSearcher event
- 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);
+ if (buildOnCommit) {
+ buildSpellIndex(newSearcher);
+ } else if (buildOnOptimize) {
+ if (newSearcher.getReader().isOptimized()) {
+ buildSpellIndex(newSearcher);
+ } 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() {
}
}