Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class SpanMultiTermQueryWrapper<Q>

    Wraps any MultiTermQuery as a SpanQuery, so it can be nested within other SpanQuery classes.

    The query is rewritten by default to a SpanOrQuery containing the expanded terms, but this can be customized.

    Example:
    WildcardQuery wildcard = new WildcardQuery(new Term("field", "bro?n"));
    SpanQuery spanWildcard = new SpanMultiTermQueryWrapper<WildcardQuery>(wildcard);
    // do something with spanWildcard, such as use it in a SpanFirstQuery
    Inheritance
    object
    Query
    SpanQuery
    SpanMultiTermQueryWrapper<Q>
    Implements
    ISpanMultiTermQueryWrapper
    Inherited Members
    SpanQuery.CreateWeight(IndexSearcher)
    Query.Boost
    Query.ToString()
    Query.ExtractTerms(ISet<Term>)
    Query.Clone()
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Search.Spans
    Assembly: Lucene.Net.dll
    Syntax
    public class SpanMultiTermQueryWrapper<Q> : SpanQuery, ISpanMultiTermQueryWrapper where Q : MultiTermQuery
    Type Parameters
    Name Description
    Q

    Constructors

    SpanMultiTermQueryWrapper(Q)

    Create a new SpanMultiTermQueryWrapper<Q>.

    Declaration
    public SpanMultiTermQueryWrapper(Q query)
    Parameters
    Type Name Description
    Q query

    Query to wrap.

    NOTE: This will set MultiTermRewriteMethod on the wrapped query, changing its rewrite method to a suitable one for spans. Be sure to not change the rewrite method on the wrapped query afterwards! Doing so will throw NotSupportedException on rewriting this query!

    Fields

    SCORING_SPAN_QUERY_REWRITE

    A rewrite method that first translates each term into a SpanTermQuery in a SHOULD clause in a BooleanQuery, and keeps the scores as computed by the query.

    Declaration
    public static readonly SpanRewriteMethod SCORING_SPAN_QUERY_REWRITE
    Field Value
    Type Description
    SpanRewriteMethod
    See Also
    MultiTermRewriteMethod

    m_query

    Wraps any MultiTermQuery as a SpanQuery, so it can be nested within other SpanQuery classes.

    The query is rewritten by default to a SpanOrQuery containing the expanded terms, but this can be customized.

    Example:
    WildcardQuery wildcard = new WildcardQuery(new Term("field", "bro?n"));
    SpanQuery spanWildcard = new SpanMultiTermQueryWrapper<WildcardQuery>(wildcard);
    // do something with spanWildcard, such as use it in a SpanFirstQuery
    Declaration
    protected readonly Q m_query
    Field Value
    Type Description
    Q

    Properties

    Field

    Returns the name of the field matched by this query.

    Note that this may return null if the query matches no terms.
    Declaration
    public override string Field { get; }
    Property Value
    Type Description
    string
    Overrides
    SpanQuery.Field

    MultiTermRewriteMethod

    Expert: Gets or Sets the rewrite method. This only makes sense to be a span rewrite method.

    Declaration
    public SpanRewriteMethod MultiTermRewriteMethod { get; set; }
    Property Value
    Type Description
    SpanRewriteMethod

    WrappedQuery

    Returns the wrapped query

    Declaration
    public virtual Query WrappedQuery { get; }
    Property Value
    Type Description
    Query

    Methods

    Equals(object)

    Determines whether the specified object is equal to the current object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current object.

    Returns
    Type Description
    bool

    true if the specified object is equal to the current object; otherwise, false.

    Overrides
    Query.Equals(object)

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    Query.GetHashCode()

    GetSpans(AtomicReaderContext, IBits, IDictionary<Term, TermContext>)

    Expert: Returns the matches for this query in an index. Used internally to search for spans.

    Declaration
    public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
    Parameters
    Type Name Description
    AtomicReaderContext context
    IBits acceptDocs
    IDictionary<Term, TermContext> termContexts
    Returns
    Type Description
    Spans
    Overrides
    SpanQuery.GetSpans(AtomicReaderContext, IBits, IDictionary<Term, TermContext>)

    Rewrite(IndexReader)

    Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

    Declaration
    public override Query Rewrite(IndexReader reader)
    Parameters
    Type Name Description
    IndexReader reader
    Returns
    Type Description
    Query
    Overrides
    Query.Rewrite(IndexReader)

    ToString(string)

    Prints a query to a string, with field assumed to be the default field and omitted.

    Declaration
    public override string ToString(string field)
    Parameters
    Type Name Description
    string field
    Returns
    Type Description
    string
    Overrides
    Query.ToString(string)

    Implements

    ISpanMultiTermQueryWrapper
    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.