org.apache.lucene.search

## Class BoostQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.search.BoostQuery

- All Implemented Interfaces:
    Cloneable

      public final class BoostQuery
      extends Query

  A `Query` wrapper that allows to give a boost to the wrapped query. Boost values that are less than one will give less importance to this query compared to other ones while values that are greater than one will give more importance to the scores returned by this query.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BoostQuery(Query query, float boost)` Sole constructor: wrap `query` in such a way that the produced scores will be boosted by `boost`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Weight` | `createWeight(IndexSearcher searcher, boolean needsScores)` Expert: Constructs an appropriate Weight implementation for this query.
    `boolean` | `equals(Object obj)`
    `float` | `getBoost()` Gets the boost for this clause.
    `Query` | `getQuery()` Return the wrapped `Query`.
    `int` | `hashCode()`
    `Query` | `rewrite(IndexReader reader)` Expert: called to re-write queries into primitive queries.
    `String` | `toString(String field)` Prints a query to a string, with `field` assumed to be the default field and omitted.

    - ### Methods inherited from class org.apache.lucene.search.Query

      `clone, setBoost, toString`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BoostQuery

          public BoostQuery(Query query,
                    float boost)

      Sole constructor: wrap `query` in such a way that the produced scores will be boosted by `boost`.

  - ### Method Detail

    - #### getQuery

          public Query getQuery()

      Return the wrapped `Query`.

    - #### getBoost

          public float getBoost()

      Description copied from class: `Query`
      Gets the boost for this clause.
      Overrides:
        `getBoost` in class `Query`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Query`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Query`

    - #### rewrite

          public Query rewrite(IndexReader reader)
                        throws IOException

      Description copied from class: `Query`
      Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
      Overrides:
        `rewrite` in class `Query`
      Throws:
        `IOException`

    - #### toString

          public String toString(String field)

      Description copied from class: `Query`
      Prints a query to a string, with `field` assumed to be the default field and omitted.
      Specified by:
        `toString` in class `Query`

    - #### createWeight

          public Weight createWeight(IndexSearcher searcher,
                            boolean needsScores)
                              throws IOException

      Description copied from class: `Query`
      Expert: Constructs an appropriate Weight implementation for this query.

      Only implemented by primitive queries, which re-write to themselves.

      Overrides:
        `createWeight` in class `Query`
        `needsScores` - True if document scores (`Scorer.score()`) or match frequencies (`Scorer.freq()`) are needed.
      Throws:
        `IOException`

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