LUCENE-3307: don't require an analyzer, if all fields are NOT_ANALYZED

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1147530 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2011-07-17 05:30:50 +00:00
parent 06891eec12
commit 561723eca6
2 changed files with 5 additions and 16 deletions

View File

@ -78,7 +78,7 @@ final class DocInverterPerField extends DocFieldConsumerPerField {
if (field.isIndexed() && doInvert) {
if (i > 0)
fieldState.position += docState.analyzer.getPositionIncrementGap(fieldInfo.name);
fieldState.position += docState.analyzer == null ? 0 : docState.analyzer.getPositionIncrementGap(fieldInfo.name);
if (!field.isTokenized()) { // un-tokenized field
String stringValue = field.stringValue();
@ -188,7 +188,7 @@ final class DocInverterPerField extends DocFieldConsumerPerField {
}
}
fieldState.offset += docState.analyzer.getOffsetGap(field);
fieldState.offset += docState.analyzer == null ? 0 : docState.analyzer.getOffsetGap(field);
fieldState.boost *= field.getBoost();
}

View File

@ -116,17 +116,6 @@ public class SpellChecker implements java.io.Closeable {
private StringDistance sd;
private Comparator<SuggestWord> comparator;
/** we don't need to actually analyze any content:
* all fields are indexed NOT_ANALYZED, but docsinverter
* needs this for the offset gap!
*/
private static Analyzer noAnalyzer = new Analyzer() {
@Override
public TokenStream tokenStream(String fieldName, Reader reader) {
return null;
}
};
/**
* Use the given directory as a spell checker index. The directory
* is created if it doesn't exist yet.
@ -182,7 +171,7 @@ public class SpellChecker implements java.io.Closeable {
if (!IndexReader.indexExists(spellIndexDir)) {
IndexWriter writer = new IndexWriter(spellIndexDir,
new IndexWriterConfig(Version.LUCENE_CURRENT,
noAnalyzer));
null));
writer.close();
}
swapSearcher(spellIndexDir);
@ -480,7 +469,7 @@ public class SpellChecker implements java.io.Closeable {
final Directory dir = this.spellIndex;
final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
Version.LUCENE_CURRENT,
noAnalyzer)
null)
.setOpenMode(OpenMode.CREATE));
writer.close();
swapSearcher(dir);
@ -517,7 +506,7 @@ public class SpellChecker implements java.io.Closeable {
synchronized (modifyCurrentIndexLock) {
ensureOpen();
final Directory dir = this.spellIndex;
final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, noAnalyzer).setRAMBufferSizeMB(ramMB));
final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, null).setRAMBufferSizeMB(ramMB));
((TieredMergePolicy) writer.getConfig().getMergePolicy()).setMaxMergeAtOnce(mergeFactor);
IndexSearcher indexSearcher = obtainSearcher();
final List<TermsEnum> termsEnums = new ArrayList<TermsEnum>();