Show / Hide Table of Contents

    Class MockAnalyzer

    Analyzer for testing.

    This analyzer is a replacement for Whitespace/Simple/KeywordAnalyzers for unit tests. If you are testing a custom component such as a queryparser or analyzer-wrapper that consumes analysis streams, its a great idea to test it with this analyzer instead. MockAnalyzer has the following behavior:

    • By default, the assertions in MockTokenizer are turned on for extra checks that the consumer is consuming properly. These checks can be disabled with EnableChecks.
    • Payload data is randomly injected into the stream for more thorough testing of payloads.

    Inheritance
    System.Object
    MockAnalyzer
    Namespace: Lucene.Net.Analysis
    Assembly: Lucene.Net.TestFramework.dll
    Syntax
    public sealed class MockAnalyzer : Analyzer

    Constructors

    | Improve this Doc View Source

    MockAnalyzer(Random)

    Create a Whitespace-lowercasing analyzer with no stopwords removal.

    Calls MockAnalyzer(random, MockTokenizer.WHITESPACE, true, MockTokenFilter.EMPTY_STOPSET, false).

    Declaration
    public MockAnalyzer(Random random)
    Parameters
    Type Name Description
    Random random
    | Improve this Doc View Source

    MockAnalyzer(Random, CharacterRunAutomaton, Boolean)

    Calls MockAnalyzer(random, runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false).

    Declaration
    public MockAnalyzer(Random random, CharacterRunAutomaton runAutomaton, bool lowerCase)
    Parameters
    Type Name Description
    Random random
    CharacterRunAutomaton runAutomaton
    System.Boolean lowerCase
    | Improve this Doc View Source

    MockAnalyzer(Random, CharacterRunAutomaton, Boolean, CharacterRunAutomaton)

    Creates a new MockAnalyzer.

    Declaration
    public MockAnalyzer(Random random, CharacterRunAutomaton runAutomaton, bool lowerCase, CharacterRunAutomaton filter)
    Parameters
    Type Name Description
    Random random

    Random for payloads behavior

    CharacterRunAutomaton runAutomaton

    DFA describing how tokenization should happen (e.g. [a-zA-Z]+)

    System.Boolean lowerCase

    true if the tokenizer should lowercase terms

    CharacterRunAutomaton filter

    DFA describing how terms should be filtered (set of stopwords, etc)

    Properties

    | Improve this Doc View Source

    EnableChecks

    Toggle consumer workflow checking: if your test consumes tokenstreams normally you should leave this enabled.

    Declaration
    public bool EnableChecks { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MaxTokenLength

    Toggle maxTokenLength for MockTokenizer.

    Declaration
    public int MaxTokenLength { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    CreateComponents(String, TextReader)

    Declaration
    protected override TokenStreamComponents CreateComponents(string fieldName, TextReader reader)
    Parameters
    Type Name Description
    System.String fieldName
    TextReader reader
    Returns
    Type Description
    TokenStreamComponents
    | Improve this Doc View Source

    GetOffsetGap(String)

    Get the offset gap between tokens in fields if several fields with the same name were added.

    Declaration
    public override int GetOffsetGap(string fieldName)
    Parameters
    Type Name Description
    System.String fieldName

    Currently not used, the same offset gap is returned for each field.

    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    GetPositionIncrementGap(String)

    Declaration
    public override int GetPositionIncrementGap(string fieldName)
    Parameters
    Type Name Description
    System.String fieldName
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    SetOffsetGap(Int32)

    Sets an offset gap which will then be added to the offset when several fields with the same name are indexed

    Declaration
    public void SetOffsetGap(int offsetGap)
    Parameters
    Type Name Description
    System.Int32 offsetGap
    | Improve this Doc View Source

    SetPositionIncrementGap(Int32)

    Declaration
    public void SetPositionIncrementGap(int positionIncrementGap)
    Parameters
    Type Name Description
    System.Int32 positionIncrementGap

    See Also

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