Matches (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.search, interface: Matches

Package org.apache.lucene.search

# Interface Matches

All Superinterfaces:
  `Iterable<String>`

All Known Implementing Classes:
  `NamedMatches`

public interface Matches extends Iterable<String>
Reports the positions and optionally offsets of all matching terms in a query for a single document

To obtain a `MatchesIterator` for a particular field, call `getMatches(String)`. Note that you can call `getMatches(String)` multiple times to retrieve new iterators, but it is not thread-safe.

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MatchesIterator`
  `getMatches(String field)`
  Returns a `MatchesIterator` over the matches for a single field, or `null` if there are no matches in that field.
  `Collection<Matches>`
  `getSubMatches()`
  Returns a collection of Matches that make up this instance; if it is not a composite, then this returns an empty list

  ### Methods inherited from interface java.lang.Iterable

  `forEach, iterator, spliterator`

- ## Method Details

  - ### getMatches

    MatchesIterator getMatches(String field) throws IOException
    Returns a `MatchesIterator` over the matches for a single field, or `null` if there are no matches in that field.
    Throws:
      `IOException`

  - ### getSubMatches

    Collection<Matches> getSubMatches()
    Returns a collection of Matches that make up this instance; if it is not a composite, then this returns an empty list