Package org.apache.lucene.search

# Class NamedMatches

java.lang.Object
org.apache.lucene.search.NamedMatches

All Implemented Interfaces:
  `Iterable<String>`, `Matches`

public class NamedMatches extends Object implements Matches
Utility class to help extract the set of sub queries that have matched from a larger query.

Individual subqueries may be wrapped using `wrapQuery(String, Query)`, and the matching queries for a particular document can then be pulled from the parent Query's `Matches` object by calling `findNamedMatches(Matches)`

## Constructor Summary

Constructors
Constructor
Description
`NamedMatches(String name, Matches in)`
Wraps a `Matches` object and associates a name with it

## Method Summary

Modifier and Type
Method
Description
`static List<NamedMatches>`
`findNamedMatches(Matches matches)`
Finds all `NamedMatches` in a `Matches` tree
`MatchesIterator`
`getMatches(String field)`
Returns a `MatchesIterator` over the matches for a single field, or `null` if there are no matches in that field.
`String`
`getName()`
Returns the name of this `Matches`
`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
`Iterator<String>`
`iterator()`
`static Query`
`wrapQuery(String name, Query in)`
Wrap a Query so that it associates a name with its `Matches`

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

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

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

`forEach, spliterator`

## Constructor Details

### NamedMatches

public NamedMatches(String name, Matches in)
Wraps a `Matches` object and associates a name with it

## Method Details

### getName

public String getName()
Returns the name of this `Matches`

### getMatches

public MatchesIterator getMatches(String field) throws IOException
Description copied from interface: `Matches`
Returns a `MatchesIterator` over the matches for a single field, or `null` if there are no matches in that field.

Specified by:
  `getMatches` in interface `Matches`
Throws:
  `IOException`

### getSubMatches

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

Specified by:
  `getSubMatches` in interface `Matches`

### iterator

public Iterator<String> iterator()

Specified by:
  `iterator` in interface `Iterable<String>`

### wrapQuery

public static Query wrapQuery(String name, Query in)
Wrap a Query so that it associates a name with its `Matches`

### findNamedMatches

public static List<NamedMatches> findNamedMatches(Matches matches)
Finds all `NamedMatches` in a `Matches` tree