org.apache.lucene.search

## Class TopTermsRewrite<B>

- java.lang.Object
- - org.apache.lucene.search.MultiTermQuery.RewriteMethod
  - - org.apache.lucene.search.TopTermsRewrite<B>

- Direct Known Subclasses:
    MultiTermQuery.TopTermsBlendedFreqScoringRewrite, MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite

      public abstract class TopTermsRewrite<B>
      extends MultiTermQuery.RewriteMethod

  Base rewrite method for collecting only the top terms via a priority queue.
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    Only public to be accessible by spans package.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TopTermsRewrite(int size)` Create a TopTermsBooleanQueryRewrite for at most `size` terms.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addClause(B topLevel, Term term, int docCount, float boost)` Add a MultiTermQuery term to the top-level query builder.
    `protected abstract void` | `addClause(B topLevel, Term term, int docCount, float boost, TermContext states)`
    `protected abstract Query` | `build(B builder)` Finalize the creation of the query from the builder.
    `boolean` | `equals(Object obj)`
    `protected abstract int` | `getMaxSize()` return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).
    `int` | `getSize()` return the maximum priority queue size
    `protected abstract B` | `getTopLevelBuilder()` Return a suitable builder for the top-level Query for holding all expanded terms.
    `int` | `hashCode()`
    `Query` | `rewrite(IndexReader reader, MultiTermQuery query)`

    - ### Methods inherited from class org.apache.lucene.search.MultiTermQuery.RewriteMethod

      `getTermsEnum`

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

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TopTermsRewrite

          public TopTermsRewrite(int size)

      Create a TopTermsBooleanQueryRewrite for at most `size` terms.

      NOTE: if `BooleanQuery.getMaxClauseCount()` is smaller than `size`, then it will be used instead.

  - ### Method Detail

    - #### getSize

          public int getSize()

      return the maximum priority queue size

    - #### getMaxSize

          protected abstract int getMaxSize()

      return the maximum size of the priority queue (for boolean rewrites this is BooleanQuery#getMaxClauseCount).

    - #### rewrite

          public final Query rewrite(IndexReader reader,
                                     MultiTermQuery query)
                              throws IOException

      Specified by:
        `rewrite` in class `MultiTermQuery.RewriteMethod`
      Throws:
        `IOException`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getTopLevelBuilder

          protected abstract B getTopLevelBuilder()
                                           throws IOException

      Return a suitable builder for the top-level Query for holding all expanded terms.
      Throws:
        `IOException`

    - #### build

          protected abstract Query build(B builder)

      Finalize the creation of the query from the builder.

    - #### addClause

          protected final void addClause(B topLevel,
                                         Term term,
                                         int docCount,
                                         float boost)
                                  throws IOException

      Add a MultiTermQuery term to the top-level query builder.
      Throws:
        `IOException`

    - #### addClause

          protected abstract void addClause(B topLevel,
                                            Term term,
                                            int docCount,
                                            float boost,
                                            TermContext states)
                                     throws IOException

      Throws:
        `IOException`

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