## helma.Search.Searcher

    Object
       |
       +--helma.Search.Searcher

This class provides basic functionality for searching an index.
Defined in Search.js

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Constructor Summary
`helma.Search.Searcher(<helma.Search.Index> index)` Creates a new instance of helma.Search.Seacher

Properties Summary
`helma.Search.HitCollection` | `hits` The search results.
`java.util.Vector` | `sortFields` A vector with SortField instances, if any have been defined.

Methods Summary
`void` | `close()` Closes the wrapped IndexSearcher instance.
`org.apache.lucene.search.IndexSearcher` | `getSearcher()` Returns the wrapped IndexSearcher instance.
`Number` | `search(<helma.Search.Query> query, <helma.Search.QueryFilter> filter)` Searches an index using the query passed as argument.
`void` | `sortBy(<String> fieldName )` Sets a field as result sorting field.

Constructor Detail

### helma.Search.Searcher

    helma.Search.Searcher(<helma.Search.Index> index)

Creates a new instance of helma.Search.Seacher

Parameters:

`index` - The index to search in.

Returns:

A newly created index searcher

Properties Detail

### hits

    helma.Search.HitCollection hits

The search results.

### sortFields

    java.util.Vector sortFields

A vector with SortField instances, if any have been defined.

Method Detail

### close

    void close()

Closes the wrapped IndexSearcher instance.

### getSearcher

    org.apache.lucene.search.IndexSearcher getSearcher()

Returns the wrapped IndexSearcher instance.

### search

    Number search(<helma.Search.Query> query, <helma.Search.QueryFilter> filter)

Searches an index using the query passed as argument. The resulting collection of hits is stored in the property "hits" of this Searcher instance. Don't forget to close the searcher when finished processing its hits.

Parameters:

`query` - The query to use for searching

`filter` - An optional query filter for filtering the results.

Returns:

The number of hits.

### sortBy

    void sortBy(<String> fieldName )

Sets a field as result sorting field. This method can be called with a different number of arguments: sortBy(fieldName) sortBy(fieldName, type) sortBy(fieldName, reverse) sortBy(fieldName, type, reverse)

Parameters:

`fieldName` - The name of the field in the index by which the search result should be ordered.

`type` - The type of the field defined by argument fieldName. Valid arguments are "string", "float", "int", "score", "doc", "auto", "custom". Default is "auto". See http://lucene.apache.org/java/docs/api/org/apache/lucene/search/SortField.html for an explanation.

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007