# Class: Search

## helma.Search()

This class provides functionality for creating a fulltext search index based on Apache Lucene.

## Constructor

#### new Search()

Constructs a new instance of helma.Search. This merely checks if the Apache Lucene library is in the application classpath.

Author:
  - Robert Gaggl
Source:
  - helma/Search.js, line 52

##### Returns:

A newly created instance of this prototype.

### Classes

BooleanQuery
Document
FuzzyQuery
HitCollection
Index
PhraseQuery
PrefixQuery
Query
QueryFilter
RangeQuery
Searcher
TermQuery
WildcardQuery

### Methods

#### createIndex(dir, analyzer)

Creates a new Lucene index in the directory passed as argument, using an optional analyzer, and returns an instance of helma.Search.Index. Any already existing index in this directory will be preserved.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dir` | org.apache.lucene.store.Directory | The directory where the index should be stored. This can be either a FSDirectory or a RAMDirectory instance.
`analyzer` | org.apache.lucene.analysis.Analyzer | The analyzer to use for the index. If not specified a StandardAnalyzer will be used.

Source:
  - helma/Search.js, line 229

##### Returns:

The index instance.

#### getDirectory(dir, create)

Returns an instance of org.apache.lucene.store.FSDirectory. If no index is present in the given directory, it is created on the fly.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dir` | File | helma.File | java.io.File | String | The directory where the index is located or should be created at.
`create` | Boolean | If true the index will be created, removing any existing index in the same directory

Source:
  - helma/Search.js, line 175

##### Returns:

The index directory.

#### getRAMDirectory(dir)

Returns a RAM directory object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dir` | File | helma.File | java.io.File | String | Optional directory containing a Lucene index from which this RAM directory should be created.

Source:
  - helma/Search.js, line 198

##### Returns:

A RAM directory instance.

#### (static) getAnalyzer(key)

Returns a new Analyzer instance depending on the key passed as argument. Currently supported arguments are "br" (BrazilianAnalyzer), "cn" (ChineseAnalyzer), "cz" (CzechAnalyzer), "nl" (DutchAnalyzer), "fr" (FrenchAnalyzer), "de" (GermanAnalyzer), "el" (GreekAnalyzer), "keyword" (KeywordAnalyzer), "ru" (RussianAnalyzer), "simple" (SimpleAnalyzer), "snowball" (SnowballAnalyzer), "stop" (StopAnalyzer) "whitespace" (WhitespaceAnalyzer). If no argument is given, a StandardAnalyzer is returned.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key identifying the analyzer

Source:
  - helma/Search.js, line 92

##### Returns:

A newly created Analyzer instance