CombinedFieldQuery (Lucene 10.5.0 sandbox API)
Description: declaration: package: org.apache.lucene.sandbox.search, class: CombinedFieldQuery

Package org.apache.lucene.sandbox.search

# Class CombinedFieldQuery

java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.sandbox.search.CombinedFieldQuery

All Implemented Interfaces:
  `Accountable`

@Deprecated public final class CombinedFieldQuery extends Query implements Accountable
Deprecated.
Use `CombinedFieldQuery` instead.
A `Query` that treats multiple fields as a single stream and scores terms as if you had indexed them as a single term in a single field.

The query works as follows:

1. Given a list of fields and weights, it pretends there is a synthetic combined field where all terms have been indexed. It computes new term and collection statistics for this combined field.
2. It uses a disjunction iterator and `IndexSearcher.getSimilarity()` to score documents.

In order for a similarity to be compatible, `Similarity.computeNorm(org.apache.lucene.index.FieldInvertState)` must be additive: the norm of the combined field is the sum of norms for each individual field. The norms must also be encoded using `SmallFloat.intToByte4(int)`. These requirements hold for all similarities that compute norms the same way as `Similarity.computeNorm(org.apache.lucene.index.FieldInvertState)`, which includes `BM25Similarity` and `DFRSimilarity`. Per-field similarities are not supported.

The query also requires that either all fields or no fields have norms enabled. Having only some fields with norms enabled can result in errors.

The scoring is based on BM25F's simple formula described in: http://www.staff.city.ac.uk/~sb317/papers/foundations_bm25_review.pdf. This query implements the same approach but allows other similarities besides `BM25Similarity`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `CombinedFieldQuery.Builder`
  Deprecated.
  A builder for `CombinedFieldQuery`.

- ## Field Summary

  ### Fields inherited from interface org.apache.lucene.util.Accountable

  `NULL_ACCOUNTABLE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Weight`
  `createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)`
  Deprecated.
  `boolean`
  `equals(Object o)`
  Deprecated.
  `List<Term>`
  `getTerms()`
  Deprecated.
  `int`
  `hashCode()`
  Deprecated.
  `long`
  `ramBytesUsed()`
  Deprecated.
  `Query`
  `rewrite(IndexSearcher indexSearcher)`
  Deprecated.
  `String`
  `toString(String field)`
  Deprecated.
  `void`
  `visit(QueryVisitor visitor)`
  Deprecated.

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

  `classHash, sameClassAs, toString`

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

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

  ### Methods inherited from interface org.apache.lucene.util.Accountable

  `getChildResources`

- ## Method Details

  - ### getTerms

    public List<Term> getTerms()
    Deprecated.

  - ### toString

    public String toString(String field)
    Deprecated.
    Specified by:
      `toString` in class `Query`

  - ### equals

    public boolean equals(Object o)
    Deprecated.
    Specified by:
      `equals` in class `Query`

  - ### hashCode

    public int hashCode()
    Deprecated.
    Specified by:
      `hashCode` in class `Query`

  - ### ramBytesUsed

    public long ramBytesUsed()
    Deprecated.
    Specified by:
      `ramBytesUsed` in interface `Accountable`

  - ### rewrite

    public Query rewrite(IndexSearcher indexSearcher) throws IOException
    Deprecated.
    Overrides:
      `rewrite` in class `Query`
    Throws:
      `IOException`

  - ### visit

    public void visit(QueryVisitor visitor)
    Deprecated.
    Specified by:
      `visit` in class `Query`

  - ### createWeight

    public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException
    Deprecated.
    Overrides:
      `createWeight` in class `Query`
    Throws:
      `IOException`