LUCENE-3306: disable positions for spellchecker ngram fields

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1145957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-07-13 11:22:31 +00:00
parent dddbb9c0a0
commit bbd85816c8
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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);