# Class: HitCollection

## helma.Search.HitCollection(hits)

This class provides Helma-like methods for accessing a collection of search hits.

## Constructor

#### new HitCollection(hits)

Creates a new instance of helma.Search.HitCollection

##### Parameters:

Name | Type | Description
--- | --- | ---
`hits` | org.lucene.search.Hits | The hit collection returned by lucene.

Source:
  - helma/Search.js, line 740

### Methods

#### forEach(fun, context)

Executes a provided function once per hit.

##### Parameters:

Name | Type | Description
--- | --- | ---
`fun` | function | Function to execute for each element
`context` | Object | Object to use as "this" when executing callback.

Source:
  - helma/Search.js, line 783
See:
  - https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Array/ForEach

#### get(idx)

Silently converts the hit at the given index position into an instance of helma.Search.Document.

##### Parameters:

Name | Type | Description
--- | --- | ---
`idx` | Number | The index position of the hit

Source:
  - helma/Search.js, line 748

##### Returns:

The document object at the given index position

#### length()

Returns the number of hits in this collection. This method is deprecated, use #size instead.

Deprecated:
  - Yes
Source:
  - helma/Search.js, line 773
See:
  - #size

##### Returns:

The number of hits.

#### size()

Returns the number of hits in this collection.

Source:
  - helma/Search.js, line 761

##### Returns:

The number of hits.