Detailed reference of prototypes, properties and methods available in the
Javascript environment of your Helma web applications.

Fields and methods of the helma.Search class

To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Search.js')
helma Search()
Constructs a new instance of helma.Search. This merely checks if the Apache Lucene library is in the application classpath.
methods
helma Search.QueryFilter(q)
Constructs a new QueryFilter instance. This class wraps a lucene QueryFilter.
parameters
helma.Search.Query q The query object to use as the basis for the QueryFilter instance.
methods
helma Search.Index(directory, analyzer)
Creates a new instance of helma.Search.Index
parameters
org.apache.lucene.store.Directory directory The directory where the Lucene index is located at.
org.apache.lucene.analysis.Analyzer analyzer The analyzer to use when modifying the index.
methods
  • count(fieldName, fieldValue)
helma Search.Searcher(index)
Creates a new instance of helma.Search.Seacher
parameters
helma.Search.Index index The index to search in.
methods
properties
  • helma.Search.HitCollection hits
helma Search.HitCollection(hits)
Creates a new instance of helma.Search.HitCollection
parameters
org.lucene.search.Hits hits The hit collection returned by lucene.
methods
helma Search.Query()
Creates a new instance of helma.Search.Query
methods
helma Search.TermQuery(field, str)
Creates a new instance of helma.Search.TermQuery
parameters
String field The name of the field
String str The value of the field
properties
  • org.apache.lucene.search.TermQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.BooleanQuery(String, String)
Creates a new instance of helma.Search.BooleanQuery
parameters
String name of the field
String query string
methods
  • addTerm(field, str, clause, analyzer)
properties
  • org.apache.lucene.search.BooleanQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.PhraseQuery(field, str)
Constructs a new helma.Search.PhraseQuery instance that wraps a Lucene Phrase Query object.
parameters
String field The name of the field
String str The phrase query string
methods
properties
  • org.apache.lucene.search.PhraseQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.RangeQuery(field, from, to, inclusive)
Constructs a new helma.Search.RangeQuery instance.
parameters
String field The name of the field
String from The minimum value to match (can be null)
String to The maximum value to match (can be null)
Boolean inclusive If true the given min/max values are included
properties
  • org.apache.lucene.search.RangeQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.FuzzyQuery(field, str)
Constructs a new helma.Search.FuzzyQuery instance.
parameters
String field The name of the field
String str The query string to match
properties
  • org.apache.lucene.search.FuzzyQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.PrefixQuery(field, str)
Constructs a new helma.Search.PrefixQuery instance.
parameters
String field The name of the field
String str The query string to match
properties
  • org.apache.lucene.search.PrefixQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.WildcardQuery(field, str)
Constructs a new helma.Search.WildcardQuery instance.
parameters
String field The name of the field
String str The query string to match
properties
  • org.apache.lucene.search.WildcardQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
helma Search.Document(document)
Creates a new instance of helma.Search.Document.
parameters
org.apache.lucene.document.Document document Optional Lucene Document object that should be wrapped by this Document instance.
methods
helma Search.Document.Field(name, value, options)
Creates a new Field instance
parameters
Object name The name of the field
Object value The value of the field
Object options Optional object containing the following properties (each of them is optional too):
  • store (String) Defines whether and how the value is stored in the field. Accepted values are "no", "yes" and "compress" (defaults to "yes")
  • index (String) Defines whether and how the value is indexed in the field. Accepted values are "no", "tokenized", "unTokenized" and "noNorms" (defaults to "tokenized")
  • termVector (String) Defines if and how the fiels should have term vectors. Accepted values are "no", "yes", "withOffsets", "withPositions" and "withPositionsAndOffsets" (defaults to "no")
methods
properties
helma.Search.HitCollection helma.Search.Searcher. hits
The search results.
java.util.Vector helma.Search.Searcher. sortFields
A vector with SortField instances, if any have been defined.
see
org.apache.lucene.search.TermQuery helma.Search.TermQuery. query
Contains the wrapped TermQuery instance
org.apache.lucene.search.BooleanQuery helma.Search.BooleanQuery. query
Contains the wrapped BooleanQuery instance
org.apache.lucene.search.PhraseQuery helma.Search.PhraseQuery. query
Contains the wrapped PhraseQuery instance
org.apache.lucene.search.RangeQuery helma.Search.RangeQuery. query
Contains the wrapped RangeQuery instance
org.apache.lucene.search.FuzzyQuery helma.Search.FuzzyQuery. query
Contains the wrapped FuzzyQuery instance
org.apache.lucene.search.PrefixQuery helma.Search.PrefixQuery. query
Contains the wrapped PrefixQuery instance
org.apache.lucene.search.WildcardQuery helma.Search.WildcardQuery. query
Contains the wrapped WildcardQuery instance
Contains the name of the field
Contains the string value of the field
String helma.Search.Document.Field. dateValue
Contains the value of the field converted into a date object.
Methods
helma. Search.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
String key The key identifying the analyzer
returns
A newly created Analyzer instance
Returns the wrapped filter instance
helma.Search. 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
File, helma.File, java.io.File, String dir The directory where the index is located or should be created at.
Boolean create If true the index will be created, removing any existing index in the same directory
returns
The index directory.
helma.Search. getRAMDirectory(dir)
Returns a RAM directory object.
parameters
File, helma.File, java.io.File, String dir Optional directory containing a Lucene index from which this RAM directory should be created.
returns
A RAM directory instance.
helma.Search. 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
org.apache.lucene.store.Directory dir The directory where the index should be stored. This can be either a FSDirectory or a RAMDirectory instance.
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.
helma.Search.Index. getWriter(create, autoCommit)
Returns an IndexWriter instance that can be used to add documents to the underlying index or to perform various other modifying operations. If the index is currently locked this method will try for the next two seconds to create the IndexWriter, otherwise it will throw an error.
parameters
Boolean create True to create the index (overwriting an existing index), false to append to an existing index. Defaults to false
Boolean autoCommit Enables or disables auto commit (defaults to false)
returns
An IndexWriter instance.
helma.Search.Index. getReader()
Returns an IndexReader instance. Due to locking issues an IndexModifier should be used for deleting documents.
returns
An IndexReader instance
helma.Search.Index. getDirectory()
Returns the directory the underlying Lucene index is located at.
returns
The directory of this index
helma.Search.Index. getAnalyzer()
Returns the analyzer used within this index.
returns
The analyzer used within this index.
helma.Search.Index. getSearcher()
Returns a searcher for querying this index.
returns
A searcher useable for querying the index.
helma.Search.Index. addIndexes(dir)
Merges the indexes passed as argument into this one.
parameters
org.apache.lucene.store.Directory dir At least one index director to add to this index.
helma.Search.Index. create()
Creates a new index. This will delete any existing index files in the directory of this index.
returns
True if creating the index was successful, false otherwise
Returns the number of documents in this index.
returns
The number of documents in this index.
helma.Search.Index. count(fieldName, fieldValue)
Returns the number of documents with the given field name and value.
parameters
String fieldName The name of the field
String fieldValue The value of the field
returns
The number of documents
helma.Search.Index. optimize()
Optimizes the underlying index.
helma.Search.Index. getFieldNames()
Returns an array containing all field names in this index.
returns
An array with the field names in this index.
helma.Search.Index. isLocked()
Checks if the index is locked.
returns
True if the underlying index is locked, false otherwise.
helma.Search.Index. unlock()
Unlocks the index. Use this with caution, as it removes any active locks in the Lucene index, which might lead to index corruption.
Closes the underlying index directory for future operations.
helma.Search.Index. addDocument(doc)
Adds a document to the index.
parameters
helma.Search.Document doc The document to add to the index.
helma.Search.Index. addDocuments(docs)
Adds all documents in the passed collection to this index.
parameters
java.util.Hashtable, java.util.Vector, Array docs The documents to add to the index.
helma.Search.Index. removeDocument(fieldName, fieldValue)
Remove all documents from the index whose field-value with the given name matches the passed value argument.
parameters
String fieldName The name of the field
String fieldValue The value of the field.
helma.Search.Index. removeDocuments(fieldName, values)
Removes all documents whose field with the given name matches the values passed as argument.
parameters
String fieldName The name of the field
java.util.Hashtable, java.util.Vector, Array values The values that define the documents that should be removed from the index.
helma.Search.Index. updateDocument(docObj, fieldName)
Updates the index with the document passed as argument. In contrast to addDocument() this removes any existing objects whose fieldName matches the one of the document object. Eg. if the document object has a field "Id" with the value "123", all document objects whose fieldName "Id" matches "123" will be removed from the index before.
parameters
helma.Search.Document docObj Document object to add to index.
String fieldName The name of the identifier field.
helma.Search.Searcher. getSearcher()
Returns the wrapped IndexSearcher instance.
helma.Search.Searcher. search(query, 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
helma.Search.Query query The query to use for searching
helma.Search.QueryFilter filter An optional query filter for filtering the results.
returns
The number of hits.
helma.Search.Searcher. sortBy(fieldName, type)
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
String fieldName The name of the field in the index by which the search result should be ordered.
String 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.
Closes the wrapped IndexSearcher instance.
Silently converts the hit at the given index position into an instance of helma.Search.Document.
parameters
Number idx The index position of the hit
returns
The document object at the given index position
Returns the number of hits in this collection.
returns
The number of hits.
helma.Search.HitCollection. length()   deprecated
Returns the number of hits in this collection. This method is deprecated, use {@link #size} instead.
returns
The number of hits.
see
helma.Search.HitCollection. forEach(fun, context)
Executes a provided function once per hit.
parameters
Function fun Function to execute for each element
Object context Object to use as "this" when executing callback.
see
helma.Search.Query. getQuery()
Returns the wrapped Lucene Query object.
returns
The wrapped query object
helma.Search.Query. getBoost()
Returns the boost factor of this query.
helma.Search.Query. setBoost(fact)
Sets the boost factor of this query clause to the given number. Documents matching this query will have their score multiplied with the given factor
parameters
Number fact The factor to multiply the score of matching documents with.
helma.Search.BooleanQuery. addTerm(field, str, clause, analyzer)
Adds a term to the wrapped query object. This method can be called with two, three or four arguments, eg.:
addTerm("fieldname", "querystring")
addTerm("fieldname", "querystring", "and")
addTerm("fieldname", "querystring", helma.Search.getAnalyzer("de"))
addTerm("fieldname", "querystring", "not", helma.Search.getAnalyzer("simple"))
parameters
String, Array field Either a String or an Array containing Strings that determine the index field(s) to match
String str Query string to match
String clause Boolean clause ("or", "not" or "and", default is "and")
org.apache.lucene.analysis.Analyzer analyzer An analyzer to use
helma.Search.BooleanQuery. addQuery(q, clause)
Adds an additional query clause to this query.
parameters
helma.Search.Query q The query to add
String clause Boolean clause ("or", "not", or "and", default is "and")
helma.Search.PhraseQuery. addTerm(field, str)
add a term to the end of the phrase query
parameters
field
str
helma.Search.Document. getDocument()
Returns the wrapped Lucene Document object
returns
The wrapped Document object
helma.Search.Document. addField(name, value, options)
Adds a field to this document.
parameters
String, helma.Search.Document.Field name The name of the field, or an instance of {@link helma.Search.Document.Field}, in which case the other arguments are ignored.
String value The value of the field
Object options Optional object containing the following properties (each of them is optional too):
  • store (String) Defines whether and how the value is stored in the field. Accepted values are "no", "yes" and "compress" (defaults to "yes")
  • index (String) Defines whether and how the value is indexed in the field. Accepted values are "no", "tokenized", "unTokenized" and "noNorms" (defaults to "tokenized")
  • termVector (String) Defines if and how the fiels should have term vectors. Accepted values are "no", "yes", "withOffsets", "withPositions" and "withPositionsAndOffsets" (defaults to "no")
helma.Search.Document. getField(name)
Returns a single document field.
parameters
String name The name of the field in this document object.
returns
The field with the given name
helma.Search.Document. getFields(name)
Returns the fields of a document object. If a name is passed as argument, this method returns only the fields with the given name
parameters
String name Optional name of the fields to return
returns
An array containing all fields in this document object.
helma.Search.Document. removeField(name)
Removes all fields with the given name from this document
parameters
String name The name of the field(s) to remove
helma.Search.Document. getBoost()
Returns the boost factor of a document.
returns
The boost factor of a document
helma.Search.Document. setBoost(boost)
Sets the boost factor of a document.
parameters
Number boost The boost factor of the document
Returns the wrapped field instance
returns
The wrapped field
helma. Search.Document.Field.valueToString(value)
Converts the value passed as argument to the appropriate string value. For null values this method returns an empty string.
parameters
Object value The value to convert into a string
returns
The value converted into a string
Returns the boost factor of this field.
returns
The boost factor of this field
helma.Search.Document.Field. setBoost(boost)
Sets the boost factor of this field.
parameters
Number boost The boost factor of this field
Returns true if this field is indexed
returns
True if this field's value is indexed, false otherwise
helma.Search.Document.Field. isCompressed()
Returns true if this field's value is stored in compressed form in the index
returns
True if this field's value is compressed, false otherwise
Returns true if this field's value is stored in the index
returns
True if this field's value is stored, false otherwise
Returns true if this field's value is tokenized
returns
True if this field's value is tokenized, false otherwise
helma.Search.Document.Field. isTermVectorStored()
Returns true if this field's term vector is stored in the index
returns
True if this field's term vector is stored, false otherwise
Fri, 05 Feb 2010 17:40:05 GMT.

core framework

optional modules

java libraries

properties files