Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-3306: disable positions for spellchecker ngram fields

Robert Muirbbd85816c807
diff --git a/lucene/contrib/CHANGES.txt b/lucene/contrib/CHANGES.txt
index 54635fd8dae..e496228670a 100644
--- a/lucene/contrib/CHANGES.txt
+++ b/lucene/contrib/CHANGES.txt
@@ -84,6 +84,12 @@ API Changes
* LUCENE-3296: PKIndexSplitter & MultiPassIndexSplitter now have version
constructors. PKIndexSplitter accepts a IndexWriterConfig for each of
the target indexes. (Simon Willnauer, Jason Rutherglen)
+
+Optimizations
+
+ * LUCENE-3306: Disabled indexing of positions for spellchecker n-gram
+ fields: they are not needed because the spellchecker does not
+ use positional queries. (Robert Muir)
Bug Fixes
diff --git a/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java b/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
index 3f1a6fd616d..2df2fab8a29 100755
--- a/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
+++ b/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
@@ -633,7 +633,11 @@ public class SpellChecker implements java.io.Closeable {
String end = null;
for (int i = 0; i < len - ng + 1; i++) {
String gram = text.substring(i, i + ng);
- doc.add(new Field(key, gram, Field.Store.NO, Field.Index.NOT_ANALYZED));
+ Field ngramField = new Field(key, gram, Field.Store.NO, Field.Index.NOT_ANALYZED);
+ // spellchecker does not use positional queries, but we want freqs
+ // for scoring these multivalued n-gram fields.
+ ngramField.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
+ doc.add(ngramField);
if (i == 0) {
// only one term possible in the startXXField, TF/pos and norms aren't needed.
Field startField = new Field("start" + ng, gram, Field.Store.NO, Field.Index.NOT_ANALYZED);