Module org.apache.lucene.suggest
Class CompletionFieldsConsumer
- java.lang.Object
-
- org.apache.lucene.codecs.FieldsConsumer
-
- org.apache.lucene.search.suggest.document.CompletionFieldsConsumer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
final class CompletionFieldsConsumer extends FieldsConsumer
Weighted FSTs for any indexedSuggestField
is built onwrite(Fields,NormsProducer)
. A weighted FST maps the analyzed forms of a field to its surface form and document id. FSTs are stored in the CompletionDictionary (.lkp).The file offsets of a field's FST are stored in the CompletionIndex (.cmp) along with the field's internal number
FieldInfo.number
onclose()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CompletionFieldsConsumer.CompletionMetaData
private static class
CompletionFieldsConsumer.CompletionTermWriter
-
Field Summary
Fields Modifier and Type Field Description private boolean
closed
private java.lang.String
codecName
private FieldsConsumer
delegateFieldsConsumer
private java.lang.String
delegatePostingsFormatName
private IndexOutput
dictOut
private java.util.Map<java.lang.String,CompletionFieldsConsumer.CompletionMetaData>
seenFields
private SegmentWriteState
state
-
Constructor Summary
Constructors Constructor Description CompletionFieldsConsumer(java.lang.String codecName, PostingsFormat delegatePostingsFormat, SegmentWriteState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
write(Fields fields, NormsProducer norms)
Write all fields, terms and postings.-
Methods inherited from class org.apache.lucene.codecs.FieldsConsumer
merge
-
-
-
-
Field Detail
-
delegatePostingsFormatName
private final java.lang.String delegatePostingsFormatName
-
seenFields
private final java.util.Map<java.lang.String,CompletionFieldsConsumer.CompletionMetaData> seenFields
-
state
private final SegmentWriteState state
-
dictOut
private IndexOutput dictOut
-
delegateFieldsConsumer
private FieldsConsumer delegateFieldsConsumer
-
codecName
private final java.lang.String codecName
-
closed
private boolean closed
-
-
Constructor Detail
-
CompletionFieldsConsumer
CompletionFieldsConsumer(java.lang.String codecName, PostingsFormat delegatePostingsFormat, SegmentWriteState state) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
write
public void write(Fields fields, NormsProducer norms) throws java.io.IOException
Description copied from class:FieldsConsumer
Write all fields, terms and postings. This the "pull" API, allowing you to iterate more than once over the postings, somewhat analogous to using a DOM API to traverse an XML tree.Notes:
- You must compute index statistics, including each Term's docFreq and totalTermFreq, as well as the summary sumTotalTermFreq, sumTotalDocFreq and docCount.
- You must skip terms that have no docs and fields that have no terms, even though the provided Fields API will expose them; this typically requires lazily writing the field or term until you've actually seen the first term or document.
- The provided Fields instance is limited: you cannot call any methods that return statistics/counts; you cannot pass a non-null live docs when pulling docs/positions enums.
- Specified by:
write
in classFieldsConsumer
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classFieldsConsumer
- Throws:
java.io.IOException
-
-