Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class PerFieldAnalyzerWrapper

    This analyzer is used to facilitate scenarios where different fields Require different analysis techniques. Use the Map argument in PerFieldAnalyzerWrapper(Analyzer, IDictionary<string, Analyzer>) to add non-default analyzers for fields.

    Example usage:

    IDictionary<string, Analyzer> analyzerPerField = new Dictionary<string, Analyzer>();
    analyzerPerField["firstname"] = new KeywordAnalyzer();
    analyzerPerField["lastname"] = new KeywordAnalyzer();
    
    PerFieldAnalyzerWrapper aWrapper =
      new PerFieldAnalyzerWrapper(new StandardAnalyzer(version), analyzerPerField);

    In this example, StandardAnalyzer will be used for all fields except "firstname" and "lastname", for which KeywordAnalyzer will be used.

    A PerFieldAnalyzerWrapper can be used like any other analyzer, for both indexing and query parsing.

    Inheritance
    object
    Analyzer
    AnalyzerWrapper
    PerFieldAnalyzerWrapper
    Implements
    IDisposable
    Inherited Members
    AnalyzerWrapper.GetPositionIncrementGap(string)
    AnalyzerWrapper.GetOffsetGap(string)
    Analyzer.NewAnonymous(Func<string, TextReader, TokenStreamComponents>)
    Analyzer.NewAnonymous(Func<string, TextReader, TokenStreamComponents>, ReuseStrategy)
    Analyzer.NewAnonymous(Func<string, TextReader, TokenStreamComponents>, Func<string, TextReader, TextReader>)
    Analyzer.NewAnonymous(Func<string, TextReader, TokenStreamComponents>, Func<string, TextReader, TextReader>, ReuseStrategy)
    Analyzer.GetTokenStream(string, TextReader)
    Analyzer.GetTokenStream(string, string)
    Analyzer.Strategy
    Analyzer.Dispose()
    Analyzer.GLOBAL_REUSE_STRATEGY
    Analyzer.PER_FIELD_REUSE_STRATEGY
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Analysis.Miscellaneous
    Assembly: Lucene.Net.Analysis.Common.dll
    Syntax
    public sealed class PerFieldAnalyzerWrapper : AnalyzerWrapper, IDisposable

    Constructors

    PerFieldAnalyzerWrapper(Analyzer)

    Constructs with default analyzer.

    Declaration
    public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer)
    Parameters
    Type Name Description
    Analyzer defaultAnalyzer

    Any fields not specifically defined to use a different analyzer will use the one provided here.

    PerFieldAnalyzerWrapper(Analyzer, IDictionary<string, Analyzer>)

    Constructs with default analyzer and a map of analyzers to use for specific fields.

    The type of IDictionary<TKey, TValue> supplied will determine the type of behavior.
    Dictionary<TKey, TValue>General use. null keys are not supported.
    SortedDictionary<TKey, TValue>Use when sorted keys are required. null keys are not supported.
    J2N.Collections.Generic.Dictionary<TKey, TValue>Similar behavior as Dictionary<TKey, TValue>. null keys are supported.
    J2N.Collections.Generic.SortedDictionary<TKey, TValue>Use when sorted keys are required. null keys are supported.
    J2N.Collections.Generic.LinkedDictionary<TKey, TValue>Use when insertion order must be preserved (Dictionary<TKey, TValue> preserves insertion order only until items are removed). null keys are supported.
    Or, use a 3rd party or custom IDictionary<TKey, TValue> if other behavior is desired.
    Declaration
    public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer, IDictionary<string, Analyzer> fieldAnalyzers)
    Parameters
    Type Name Description
    Analyzer defaultAnalyzer

    Any fields not specifically defined to use a different analyzer will use the one provided here.

    IDictionary<string, Analyzer> fieldAnalyzers

    A IDictionary<TKey, TValue> (String field name to the Analyzer) to be used for those fields.

    Methods

    GetWrappedAnalyzer(string)

    Retrieves the wrapped Lucene.Net.Analysis.Analyzer appropriate for analyzing the field with the given name

    Declaration
    protected override Analyzer GetWrappedAnalyzer(string fieldName)
    Parameters
    Type Name Description
    string fieldName

    Name of the field which is to be analyzed

    Returns
    Type Description
    Analyzer

    Lucene.Net.Analysis.Analyzer for the field with the given name. Assumed to be non-null

    Overrides
    AnalyzerWrapper.GetWrappedAnalyzer(string)

    ToString()

    Returns a string that represents the current object.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the current object.

    Overrides
    object.ToString()

    Implements

    IDisposable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.