Show / Hide Table of Contents

    Class DefaultPostingsFormatFactory

    LUCENENET specific class that implements the default functionality for the IPostingsFormatFactory.

    The most common use cases are:

    • Initialize DefaultPostingsFormatFactory with a set of CustomPostingsFormatTypes.
    • Subclass DefaultPostingsFormatFactory and override GetPostingsFormat(Type) so an external dependency injection container can be used to supply the instances (lifetime should be singleton). Note that you could alternately use the "named type" feature that many DI containers have to supply the type based on name by overriding GetPostingsFormat(String).
    • Subclass DefaultPostingsFormatFactory and override GetPostingsFormatType(String) so a type new type can be supplied that is not in the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap.
    • Subclass DefaultPostingsFormatFactory to add new or override the default PostingsFormat types by overriding Initialize() and calling PutPostingsFormatType(Type).
    • Subclass DefaultPostingsFormatFactory to scan additional assemblies for PostingsFormat subclasses in by overriding Initialize() and calling ScanForPostingsFormats(Assembly). For performance reasons, the default behavior only loads Lucene.Net codecs.

    To set the IPostingsFormatFactory, call SetPostingsFormatFactory(IPostingsFormatFactory).

    Inheritance
    System.Object
    NamedServiceFactory<PostingsFormat>
    DefaultPostingsFormatFactory
    Implements
    IPostingsFormatFactory
    IServiceListable
    Inherited Members
    NamedServiceFactory<PostingsFormat>.m_initializationLock
    NamedServiceFactory<PostingsFormat>.EnsureInitialized()
    NamedServiceFactory<PostingsFormat>.CodecsAssembly
    NamedServiceFactory<PostingsFormat>.IsServiceType(Type)
    NamedServiceFactory<PostingsFormat>.GetServiceName(Type)
    NamedServiceFactory<PostingsFormat>.GetCanonicalName(Type)
    NamedServiceFactory<PostingsFormat>.IsFullyTrusted
    Namespace: Lucene.Net.Codecs
    Assembly: Lucene.Net.dll
    Syntax
    public class DefaultPostingsFormatFactory : NamedServiceFactory<PostingsFormat>, IPostingsFormatFactory, IServiceListable

    Constructors

    | Improve this Doc View Source

    DefaultPostingsFormatFactory()

    Creates a new instance of DefaultPostingsFormatFactory.

    Declaration
    public DefaultPostingsFormatFactory()

    Properties

    | Improve this Doc View Source

    AvailableServices

    Gets a list of the available PostingsFormats (by name).

    Declaration
    public virtual ICollection<string> AvailableServices { get; }
    Property Value
    Type Description
    ICollection<System.String>

    A ICollection{string} of PostingsFormat names.

    | Improve this Doc View Source

    CustomPostingsFormatTypes

    An array of custom PostingsFormat-derived types to be registered. This property can be initialized during construction of DefaultPostingsFormatFactory to make your custom codecs known to Lucene.

    These types will be registered after the default Lucene types, so if a custom type has the same name as a Lucene PostingsFormat (via PostingsFormatNameAttribute) the custom type will replace the Lucene type with the same name.

    Declaration
    public IEnumerable<Type> CustomPostingsFormatTypes { get; set; }
    Property Value
    Type Description
    IEnumerable<Type>

    Methods

    | Improve this Doc View Source

    GetPostingsFormat(String)

    Gets the PostingsFormat instance from the provided name.

    Declaration
    public virtual PostingsFormat GetPostingsFormat(string name)
    Parameters
    Type Name Description
    System.String name

    The name of the PostingsFormat instance to retrieve.

    Returns
    Type Description
    PostingsFormat

    The PostingsFormat instance.

    | Improve this Doc View Source

    GetPostingsFormat(Type)

    Gets the PostingsFormat instance from the provided type.

    Declaration
    protected virtual PostingsFormat GetPostingsFormat(Type type)
    Parameters
    Type Name Description
    Type type

    The of PostingsFormat to retrieve.

    Returns
    Type Description
    PostingsFormat

    The PostingsFormat instance.

    | Improve this Doc View Source

    GetPostingsFormatType(String)

    Gets the PostingsFormat from the provided name.

    Declaration
    protected virtual Type GetPostingsFormatType(string name)
    Parameters
    Type Name Description
    System.String name

    The name of the PostingsFormat to retrieve.

    Returns
    Type Description
    Type

    The PostingsFormat .

    | Improve this Doc View Source

    Initialize()

    Initializes the codec type cache with the known PostingsFormat types. Override this method (and optionally call base.Initialize()) to add your own PostingsFormat types by calling PutPostingsFormatType(Type) or ScanForPostingsFormats(Assembly).

    If two types have the same name by using the PostingsFormatNameAttribute, the last one registered wins.

    Declaration
    protected override void Initialize()
    Overrides
    Lucene.Net.Util.NamedServiceFactory<Lucene.Net.Codecs.PostingsFormat>.Initialize()
    | Improve this Doc View Source

    NewPostingsFormat(Type)

    Instantiates a PostingsFormat based on the provided type.

    Declaration
    protected virtual PostingsFormat NewPostingsFormat(Type type)
    Parameters
    Type Name Description
    Type type

    The of PostingsFormat to instantiate.

    Returns
    Type Description
    PostingsFormat

    The new instance.

    | Improve this Doc View Source

    PutPostingsFormatType(Type)

    Adds a PostingsFormat type to the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap, using the name provided in the PostingsFormatNameAttribute, if present, or the name of the codec class minus the "Codec" suffix as the name by default.

    Note that if a PostingsFormat with the same name already exists in the map, calling this method will update it to the new type.

    Declaration
    protected virtual void PutPostingsFormatType(Type postingsFormat)
    Parameters
    Type Name Description
    Type postingsFormat

    A type that subclasses PostingsFormat.

    | Improve this Doc View Source

    ScanForPostingsFormats(Assembly)

    Scans the given assembly for subclasses of PostingsFormat and adds their names to the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap. Note that names will be automatically overridden if the PostingsFormat name appears multiple times - the last match wins.

    Declaration
    protected virtual void ScanForPostingsFormats(Assembly assembly)
    Parameters
    Type Name Description
    Assembly assembly

    The assembly to scan.

    | Improve this Doc View Source

    ScanForPostingsFormats(IEnumerable<Assembly>)

    Scans the given assemblies for subclasses of Codec and adds their names to the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap. Note that names will be automatically overridden if the PostingsFormat name appears multiple times - the last match wins.

    Declaration
    protected virtual void ScanForPostingsFormats(IEnumerable<Assembly> assemblies)
    Parameters
    Type Name Description
    IEnumerable<Assembly> assemblies

    A list of assemblies to scan. The assemblies will be scanned from first to last, and the last match for each PostingsFormat name wins.

    Implements

    IPostingsFormatFactory
    IServiceListable
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)