Global.helma.Search.prototype.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.

  • Parameter {org.apache.lucene.store.Directory}:
    dir The directory where the index should be stored. This can be either a FSDirectory or a RAMDirectory instance.
  • Parameter {org.apache.lucene.analysis.Analyzer}:
    analyzer The analyzer to use for the index. If not specified a StandardAnalyzer will be used.
  • Returns
    The index instance.
Sourcecode in /home/hannes/helma/modules/helma/Search.js:
208:   helma.Search.prototype.createIndex = function(dir, analyzer) {
209:       if (!dir || !(dir instanceof Packages.org.apache.lucene.store.Directory)) {
210:           throw("Index directory missing or invalid.");
211:       } else if (!analyzer) {
212:           // no analyzer given, use a StandardAnalyzer
213:           analyzer = helma.Search.getAnalyzer();
214:       }
215:       var index = new helma.Search.Index(dir, analyzer);
216:       if (!Packages.org.apache.lucene.index.IndexReader.indexExists(dir)) {
217:          index.create();
218:      }
219:      return index;
220:  }