org.apache.lucene.search.suggest.document

## Class CompletionPostingsFormat

- java.lang.Object
- - org.apache.lucene.codecs.PostingsFormat
  - - org.apache.lucene.search.suggest.document.CompletionPostingsFormat

- All Implemented Interfaces:
    NamedSPILoader.NamedSPI
  Direct Known Subclasses:
    Completion50PostingsFormat

      public abstract class CompletionPostingsFormat
      extends PostingsFormat

  A `PostingsFormat` which supports document suggestion based on indexed `SuggestField`s. Document suggestion is based on an weighted FST which map analyzed terms of a `SuggestField` to its surface form and document id.

  Files:

  - `.lkp`: Completion Dictionary
  - `.cmp`: Completion Index

  ### Completion Dictionary

  The .lkp file contains an FST for each suggest field

  - CompletionDict (.lkp) --> Header, FSTNumSuggestFields, Footer
  - Header --> `CodecHeader`
  - FST --> `FST<Long, BytesRef>`
  - Footer --> `CodecFooter`

  Notes:

  - Header is a `CodecHeader` storing the version information for the Completion implementation.
  - FST maps all analyzed forms to surface forms of a SuggestField

  ### Completion Index

  The .cmp file contains an index into the completion dictionary, so that it can be accessed randomly.

  - CompletionIndex (.cmp) --> Header, NumSuggestFields, EntryNumSuggestFields, Footer
  - Header --> `CodecHeader`
  - NumSuggestFields --> `Uint32`
  - Entry --> FieldNumber, CompletionDictionaryOffset, MinWeight, MaxWeight, Type
  - FieldNumber --> `Uint32`
  - CompletionDictionaryOffset --> `Uint64`
  - MinWeight --> `Uint64`
  - MaxWeight --> `Uint64`
  - Type --> `Byte`
  - Footer --> `CodecFooter`

  Notes:

  - Header is a `CodecHeader` storing the version information for the Completion implementation.
  - NumSuggestFields is the number of suggest fields indexed
  - FieldNumber is the fields number from `FieldInfos`. (.fnm)
  - CompletionDictionaryOffset is the file offset of a field's FST in CompletionDictionary (.lkp)
  - MinWeight and MaxWeight are the global minimum and maximum weight for the field
  - Type indicates if the suggester has context or not
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.codecs.PostingsFormat

      `EMPTY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompletionPostingsFormat()` Used only by core Lucene at read-time via Service Provider instantiation

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract PostingsFormat` | `delegatePostingsFormat()` Concrete implementation should specify the delegating postings format
    `FieldsConsumer` | `fieldsConsumer(SegmentWriteState state)`
    `FieldsProducer` | `fieldsProducer(SegmentReadState state)`

    - ### Methods inherited from class org.apache.lucene.codecs.PostingsFormat

      `availablePostingsFormats, forName, getName, reloadPostingsFormats, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CompletionPostingsFormat

          public CompletionPostingsFormat()

      Used only by core Lucene at read-time via Service Provider instantiation

  - ### Method Detail

    - #### delegatePostingsFormat

          protected abstract PostingsFormat delegatePostingsFormat()

      Concrete implementation should specify the delegating postings format

    - #### fieldsConsumer

          public FieldsConsumer fieldsConsumer(SegmentWriteState state)
                                        throws IOException

      Specified by:
        `fieldsConsumer` in class `PostingsFormat`
      Throws:
        `IOException`

    - #### fieldsProducer

          public FieldsProducer fieldsProducer(SegmentReadState state)
                                        throws IOException

      Specified by:
        `fieldsProducer` in class `PostingsFormat`
      Throws:
        `IOException`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.