changed inline documentation for JsDoc compatibility
This commit is contained in:
parent
b11fce933f
commit
dcc0accdb3
1 changed files with 151 additions and 96 deletions
247
helma/Search.js
247
helma/Search.js
|
@ -17,12 +17,16 @@
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// $Revision: 1.6 $
|
// $Revision: 1.7 $
|
||||||
// $Author: robert $
|
// $Author: hannes $
|
||||||
// $Date: 2006/11/13 16:56:45 $
|
// $Date: 2006/11/27 12:32:36 $
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fileoverview Fields and methods of the helma.Search class
|
||||||
|
*/
|
||||||
|
|
||||||
// take care of any dependencies
|
// take care of any dependencies
|
||||||
app.addRepository('modules/helma/lucene-core.jar');
|
app.addRepository('modules/helma/lucene-core.jar');
|
||||||
app.addRepository('modules/helma/lucene-analyzers.jar');
|
app.addRepository('modules/helma/lucene-analyzers.jar');
|
||||||
|
@ -33,12 +37,12 @@ if (!global.helma) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance of Search. This merely
|
* Constructs a new instance of helma.Search. This merely
|
||||||
* checks if the Lucene library is in the application
|
* checks if the Apache Lucene library is in the application
|
||||||
* classpath.
|
* classpath.
|
||||||
* @classDescription This class provides functionality for
|
* @class This class provides functionality for
|
||||||
* creating a search index.
|
* creating a fulltext search index based on Apache Lucene.
|
||||||
* @return A newly created instance of this prototype.
|
* @returns A newly created instance of this prototype.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
helma.Search = function() {
|
helma.Search = function() {
|
||||||
|
@ -55,11 +59,11 @@ helma.Search = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**********************
|
/***************************************
|
||||||
* STATIC METHODS *
|
***** S T A T I C M E T H O D S *****
|
||||||
**********************/
|
***************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/** @ignore */
|
||||||
helma.Search.toString = function() {
|
helma.Search.toString = function() {
|
||||||
return "[helma.Search]";
|
return "[helma.Search]";
|
||||||
};
|
};
|
||||||
|
@ -74,7 +78,7 @@ helma.Search.toString = function() {
|
||||||
* "whitespace" (WhitespaceAnalyzer). If no argument is given, a StandardAnalyzer
|
* "whitespace" (WhitespaceAnalyzer). If no argument is given, a StandardAnalyzer
|
||||||
* is returned.
|
* is returned.
|
||||||
* @param {String} key The key identifying the analyzer
|
* @param {String} key The key identifying the analyzer
|
||||||
* @return A newly created Analyzer instance
|
* @returns A newly created Analyzer instance
|
||||||
* @type {org.apache.lucene.analysis.Analyzer}
|
* @type {org.apache.lucene.analysis.Analyzer}
|
||||||
*/
|
*/
|
||||||
helma.Search.getAnalyzer = function(key) {
|
helma.Search.getAnalyzer = function(key) {
|
||||||
|
@ -116,16 +120,21 @@ helma.Search.getAnalyzer = function(key) {
|
||||||
* wraps a lucene QueryFilter.
|
* wraps a lucene QueryFilter.
|
||||||
* @param {helma.Search.Query} q The query object to use as
|
* @param {helma.Search.Query} q The query object to use as
|
||||||
* the basis for the QueryFilter instance.
|
* the basis for the QueryFilter instance.
|
||||||
* @return A newly created QueryFilter instance.
|
* @returns A newly created QueryFilter instance.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
helma.Search.QueryFilter = function(q) {
|
helma.Search.QueryFilter = function(q) {
|
||||||
var wrappedFilter = new Packages.org.apache.lucene.search.QueryFilter(q.getQuery());
|
var wrappedFilter = new Packages.org.apache.lucene.search.QueryFilter(q.getQuery());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the wrapped filter instance
|
||||||
|
* @type org.apache.lucene.search.QueryFilter
|
||||||
|
*/
|
||||||
this.getFilter = function() {
|
this.getFilter = function() {
|
||||||
return wrappedFilter;
|
return wrappedFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @ignore */
|
||||||
this.toString = function() {
|
this.toString = function() {
|
||||||
return wrappedFilter.toString();
|
return wrappedFilter.toString();
|
||||||
};
|
};
|
||||||
|
@ -134,9 +143,9 @@ helma.Search.QueryFilter = function(q) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*********************************************
|
||||||
* PROTOTYPE METHODS *
|
***** P R O T O T Y P E M E T H O D S *****
|
||||||
*************************/
|
*********************************************/
|
||||||
|
|
||||||
|
|
||||||
/** @ignore */
|
/** @ignore */
|
||||||
|
@ -145,10 +154,13 @@ helma.Search.prototype.toString = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an instance of org.apache.lucene.store.FSDirectory
|
* Returns an instance of org.apache.lucene.store.FSDirectory. If
|
||||||
* @param {File | helma.File | java.io.File | String} dir The directory
|
* no index is present in the given directory, it is created on the fly.
|
||||||
|
* @param {File|helma.File|java.io.File|String} dir The directory
|
||||||
* where the index is located or should be created at.
|
* where the index is located or should be created at.
|
||||||
* @return The index directory.
|
* @param {Boolean} create If true the index will be created, removing
|
||||||
|
* any existing index in the same directory
|
||||||
|
* @returns The index directory.
|
||||||
* @type org.apache.lucene.store.FSDirectory
|
* @type org.apache.lucene.store.FSDirectory
|
||||||
*/
|
*/
|
||||||
helma.Search.prototype.getDirectory = function(dir, create) {
|
helma.Search.prototype.getDirectory = function(dir, create) {
|
||||||
|
@ -169,9 +181,9 @@ helma.Search.prototype.getDirectory = function(dir, create) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a RAM directory object.
|
* Returns a RAM directory object.
|
||||||
* @param {File | helma.File | java.io.File | String} dir Optional directory
|
* @param {File|helma.File|java.io.File|String} dir Optional directory
|
||||||
* containing a Lucene index from which this RAM directory should be created.
|
* containing a Lucene index from which this RAM directory should be created.
|
||||||
* @return A RAM directory instance.
|
* @returns A RAM directory instance.
|
||||||
* @type org.apache.lucene.store.RAMDirectory
|
* @type org.apache.lucene.store.RAMDirectory
|
||||||
*/
|
*/
|
||||||
helma.Search.prototype.getRAMDirectory = function(dir) {
|
helma.Search.prototype.getRAMDirectory = function(dir) {
|
||||||
|
@ -202,7 +214,7 @@ helma.Search.prototype.getRAMDirectory = function(dir) {
|
||||||
* FSDirectory or a RAMDirectory instance.
|
* FSDirectory or a RAMDirectory instance.
|
||||||
* @param {org.apache.lucene.analysis.Analyzer} analyzer The analyzer to
|
* @param {org.apache.lucene.analysis.Analyzer} analyzer The analyzer to
|
||||||
* use for the index. If not specified a StandardAnalyzer will be used.
|
* use for the index. If not specified a StandardAnalyzer will be used.
|
||||||
* @return The index instance.
|
* @returns The index instance.
|
||||||
* @type helma.Search.Index
|
* @type helma.Search.Index
|
||||||
*/
|
*/
|
||||||
helma.Search.prototype.createIndex = function(dir, analyzer) {
|
helma.Search.prototype.createIndex = function(dir, analyzer) {
|
||||||
|
@ -220,12 +232,13 @@ helma.Search.prototype.createIndex = function(dir, analyzer) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*************
|
/*********************
|
||||||
* INDEX *
|
***** I N D E X *****
|
||||||
*************/
|
*********************/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new instance of helma.Search.Index
|
||||||
* @class Instances of this class represent a Lucene search index
|
* @class Instances of this class represent a Lucene search index
|
||||||
* located in either a directory on disk or in RAM. This class
|
* located in either a directory on disk or in RAM. This class
|
||||||
* provides various methods for modifying the underlying Lucene index.
|
* provides various methods for modifying the underlying Lucene index.
|
||||||
|
@ -266,7 +279,7 @@ helma.Search.Index = function(directory, analyzer) {
|
||||||
* index is currently locked this method will try for the next
|
* index is currently locked this method will try for the next
|
||||||
* two seconds to create the IndexModifier, otherwise it will
|
* two seconds to create the IndexModifier, otherwise it will
|
||||||
* throw an error.
|
* throw an error.
|
||||||
* @return An IndexModifier instance.
|
* @returns An IndexModifier instance.
|
||||||
* @type org.apache.lucene.index.IndexModifier
|
* @type org.apache.lucene.index.IndexModifier
|
||||||
*/
|
*/
|
||||||
this.getModifier = function(create) {
|
this.getModifier = function(create) {
|
||||||
|
@ -279,7 +292,7 @@ helma.Search.Index = function(directory, analyzer) {
|
||||||
* If the index is currently locked this method will try for the next
|
* If the index is currently locked this method will try for the next
|
||||||
* two seconds to create the IndexWriter, otherwise it will
|
* two seconds to create the IndexWriter, otherwise it will
|
||||||
* throw an error.
|
* throw an error.
|
||||||
* @return An IndexWriter instance.
|
* @returns An IndexWriter instance.
|
||||||
* @type org.apache.lucene.index.IndexWriter
|
* @type org.apache.lucene.index.IndexWriter
|
||||||
*/
|
*/
|
||||||
this.getWriter = function(create) {
|
this.getWriter = function(create) {
|
||||||
|
@ -289,7 +302,7 @@ helma.Search.Index = function(directory, analyzer) {
|
||||||
/**
|
/**
|
||||||
* Returns an IndexReader instance. Due to locking issues an
|
* Returns an IndexReader instance. Due to locking issues an
|
||||||
* IndexModifier should be used for deleting documents.
|
* IndexModifier should be used for deleting documents.
|
||||||
* @return An IndexReader instance
|
* @returns An IndexReader instance
|
||||||
* @type org.apache.lucene.index.IndexReader
|
* @type org.apache.lucene.index.IndexReader
|
||||||
*/
|
*/
|
||||||
this.getReader = function() {
|
this.getReader = function() {
|
||||||
|
@ -298,7 +311,7 @@ helma.Search.Index = function(directory, analyzer) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the directory the underlying Lucene index is located at.
|
* Returns the directory the underlying Lucene index is located at.
|
||||||
* @return The directory of this index
|
* @returns The directory of this index
|
||||||
* @type org.apache.lucene.store.Directory
|
* @type org.apache.lucene.store.Directory
|
||||||
*/
|
*/
|
||||||
this.getDirectory = function() {
|
this.getDirectory = function() {
|
||||||
|
@ -307,7 +320,7 @@ helma.Search.Index = function(directory, analyzer) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the analyzer used within this index.
|
* Returns the analyzer used within this index.
|
||||||
* @return The analyzer used within this index.
|
* @returns The analyzer used within this index.
|
||||||
* @type org.apache.lucene.analysis.Analyer
|
* @type org.apache.lucene.analysis.Analyer
|
||||||
*/
|
*/
|
||||||
this.getAnalyzer = function() {
|
this.getAnalyzer = function() {
|
||||||
|
@ -316,7 +329,7 @@ helma.Search.Index = function(directory, analyzer) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a searcher for querying this index.
|
* Returns a searcher for querying this index.
|
||||||
* @return A searcher useable for querying the index.
|
* @returns A searcher useable for querying the index.
|
||||||
* @type helma.Search.Searcher
|
* @type helma.Search.Searcher
|
||||||
*/
|
*/
|
||||||
this.getSearcher = function() {
|
this.getSearcher = function() {
|
||||||
|
@ -364,6 +377,8 @@ helma.Search.Index.prototype.addIndexes = function(dir /* [, dir[, dir...] */) {
|
||||||
/**
|
/**
|
||||||
* Creates a new index. This will delete any existing index
|
* Creates a new index. This will delete any existing index
|
||||||
* files in the directory of this index.
|
* files in the directory of this index.
|
||||||
|
* @returns True if creating the index was successful, false otherwise
|
||||||
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
helma.Search.Index.prototype.create = function() {
|
helma.Search.Index.prototype.create = function() {
|
||||||
try {
|
try {
|
||||||
|
@ -375,17 +390,19 @@ helma.Search.Index.prototype.create = function() {
|
||||||
Packages.org.apache.lucene.store.FSDirectory.getDirectory(dir, true);
|
Packages.org.apache.lucene.store.FSDirectory.getDirectory(dir, true);
|
||||||
var writer = this.getWriter(true);
|
var writer = this.getWriter(true);
|
||||||
return true;
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
app.logger.warn("Unable to create the index " + this.getDirectory());
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of documents in this index.
|
* Returns the number of documents in this index.
|
||||||
* @return The number of documents in this index.
|
* @returns The number of documents in this index.
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
helma.Search.Index.prototype.size = function() {
|
helma.Search.Index.prototype.size = function() {
|
||||||
|
@ -417,7 +434,7 @@ helma.Search.Index.prototype.optimize = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing all field names in this index.
|
* Returns an array containing all field names in this index.
|
||||||
* @return An array with the field names in this index.
|
* @returns An array with the field names in this index.
|
||||||
* @type Array
|
* @type Array
|
||||||
*/
|
*/
|
||||||
helma.Search.Index.prototype.getFieldNames = function() {
|
helma.Search.Index.prototype.getFieldNames = function() {
|
||||||
|
@ -440,7 +457,7 @@ helma.Search.Index.prototype.getFieldNames = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the index is locked.
|
* Checks if the index is locked.
|
||||||
* @return True if the underlying index is locked,
|
* @returns True if the underlying index is locked,
|
||||||
* false otherwise.
|
* false otherwise.
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
|
@ -484,7 +501,7 @@ helma.Search.Index.prototype.addDocument = function(doc) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds all documents in the passed collection to this index.
|
* Adds all documents in the passed collection to this index.
|
||||||
* @param {java.util.Hashtable | java.util.Vector | Array} docs
|
* @param {java.util.Hashtable|java.util.Vector|Array} docs
|
||||||
* The documents to add to the index.
|
* The documents to add to the index.
|
||||||
*/
|
*/
|
||||||
helma.Search.Index.prototype.addDocuments = function(docs, mergeFactor) {
|
helma.Search.Index.prototype.addDocuments = function(docs, mergeFactor) {
|
||||||
|
@ -516,7 +533,7 @@ helma.Search.Index.prototype.addDocuments = function(docs, mergeFactor) {
|
||||||
* with the given name matches the passed value argument.
|
* with the given name matches the passed value argument.
|
||||||
* @param {String} fieldName The name of the field
|
* @param {String} fieldName The name of the field
|
||||||
* @param {String} fieldValue The value of the field.
|
* @param {String} fieldValue The value of the field.
|
||||||
* @return The number of documents that have been deleted.
|
* @returns The number of documents that have been deleted.
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
helma.Search.Index.prototype.removeDocument = function(fieldName, fieldValue) {
|
helma.Search.Index.prototype.removeDocument = function(fieldName, fieldValue) {
|
||||||
|
@ -537,11 +554,12 @@ helma.Search.Index.prototype.removeDocument = function(fieldName, fieldValue) {
|
||||||
* Removes all documents whose field with the given name matches
|
* Removes all documents whose field with the given name matches
|
||||||
* the values passed as argument.
|
* the values passed as argument.
|
||||||
* @param {String} fieldName The name of the field
|
* @param {String} fieldName The name of the field
|
||||||
* @param {java.util.Hashtable | java.util.Vector | Array} values
|
* @param {java.util.Hashtable|java.util.Vector|Array} values
|
||||||
* The values that define the documents that should be removed from
|
* The values that define the documents that should be removed from
|
||||||
* the index.
|
* the index.
|
||||||
* @return An array containing the numbers of deleted documents
|
* @returns An array containing the numbers of deleted documents
|
||||||
* for each field value.
|
* for each field value.
|
||||||
|
* @type Array
|
||||||
*/
|
*/
|
||||||
helma.Search.Index.prototype.removeDocuments = function(fieldName, values) {
|
helma.Search.Index.prototype.removeDocuments = function(fieldName, values) {
|
||||||
try {
|
try {
|
||||||
|
@ -594,10 +612,11 @@ helma.Search.Index.prototype.updateDocument = function(docObj, fieldName) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new instance of helma.Search.Seacher
|
||||||
* @class This class provides basic functionality for
|
* @class This class provides basic functionality for
|
||||||
* searching an index.
|
* searching an index.
|
||||||
* @param {helma.Search.Index} index The index to search in.
|
* @param {helma.Search.Index} index The index to search in.
|
||||||
* @return A newly created index searcher
|
* @returns A newly created index searcher
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
helma.Search.Searcher = function(index) {
|
helma.Search.Searcher = function(index) {
|
||||||
|
@ -640,7 +659,7 @@ helma.Search.Searcher.prototype.toString = function() {
|
||||||
* @param {helma.Search.Query} query The query to use for searching
|
* @param {helma.Search.Query} query The query to use for searching
|
||||||
* @param {helma.Search.QueryFilter} filter An optional query filter
|
* @param {helma.Search.QueryFilter} filter An optional query filter
|
||||||
* for filtering the results.
|
* for filtering the results.
|
||||||
* @return The number of hits.
|
* @returns The number of hits.
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
helma.Search.Searcher.prototype.search = function(query, filter) {
|
helma.Search.Searcher.prototype.search = function(query, filter) {
|
||||||
|
@ -710,6 +729,7 @@ helma.Search.Searcher.prototype.close = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new instance of helma.Search.HitCollection
|
||||||
* @class This class provides Helma-like methods for accessing
|
* @class This class provides Helma-like methods for accessing
|
||||||
* a collection of search hits.
|
* a collection of search hits.
|
||||||
* @param {org.lucene.search.Hits} hits The hit collection returned
|
* @param {org.lucene.search.Hits} hits The hit collection returned
|
||||||
|
@ -721,7 +741,7 @@ helma.Search.HitCollection = function(hits) {
|
||||||
* Silently converts the hit at the given index position into
|
* Silently converts the hit at the given index position into
|
||||||
* an instance of helma.Search.Document.
|
* an instance of helma.Search.Document.
|
||||||
* @param {Number} idx The index position of the hit
|
* @param {Number} idx The index position of the hit
|
||||||
* @return The document object at the given index position
|
* @returns The document object at the given index position
|
||||||
* @type helma.Search.Document
|
* @type helma.Search.Document
|
||||||
*/
|
*/
|
||||||
this.get = function(idx) {
|
this.get = function(idx) {
|
||||||
|
@ -733,22 +753,31 @@ helma.Search.HitCollection = function(hits) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of hits in this collection.
|
* Returns the number of hits in this collection.
|
||||||
* @return The number of hits.
|
* @returns The number of hits.
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
this.size = this.length = function() {
|
this.size = function() {
|
||||||
return (hits != null) ? hits.length() : 0;
|
return (hits != null) ? hits.length() : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of hits in this collection
|
||||||
|
* @returns The number of hits.
|
||||||
|
* @type Number
|
||||||
|
* @deprecated
|
||||||
|
* @see #size
|
||||||
|
*/
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************************
|
/***********************************************
|
||||||
* QUERY CONSTRUCTORS *
|
***** Q U E R Y C O N S T R U C T O R S *****
|
||||||
**************************/
|
***********************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new instance of helma.Search.Query
|
||||||
* @class Base class for the various query constructors. Don't
|
* @class Base class for the various query constructors. Don't
|
||||||
* call this directly, as it provides just basic methods used
|
* call this directly, as it provides just basic methods used
|
||||||
* in all of its extends.
|
* in all of its extends.
|
||||||
|
@ -767,7 +796,7 @@ helma.Search.Query = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the wrapped Lucene Query object.
|
* Returns the wrapped Lucene Query object.
|
||||||
* @return The wrapped query object
|
* @returns The wrapped query object
|
||||||
* @type org.apache.lucene.search.Query
|
* @type org.apache.lucene.search.Query
|
||||||
*/
|
*/
|
||||||
helma.Search.Query.prototype.getQuery = function() {
|
helma.Search.Query.prototype.getQuery = function() {
|
||||||
|
@ -801,7 +830,7 @@ helma.Search.Query.prototype.setBoost = function(fact) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Term Query constructor
|
* Creates a new instance of helma.Search.TermQuery
|
||||||
* @class This class represents a simple Term Query.
|
* @class This class represents a simple Term Query.
|
||||||
* @param {String} field The name of the field
|
* @param {String} field The name of the field
|
||||||
* @param {String} str The value of the field
|
* @param {String} str The value of the field
|
||||||
|
@ -810,22 +839,30 @@ helma.Search.Query.prototype.setBoost = function(fact) {
|
||||||
*/
|
*/
|
||||||
helma.Search.TermQuery = function(field, str) {
|
helma.Search.TermQuery = function(field, str) {
|
||||||
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
||||||
|
/**
|
||||||
|
* Contains the wrapped TermQuery instance
|
||||||
|
* @type org.apache.lucene.search.TermQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.TermQuery(t);
|
this.query = new Packages.org.apache.lucene.search.TermQuery(t);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
helma.Search.TermQuery.prototype = new helma.Search.Query;
|
helma.Search.TermQuery.prototype = new helma.Search.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean Query constructor
|
* Creates a new instance of helma.Search.BooleanQuery
|
||||||
* @class This class represents a Boolean Query, providing
|
* @class This class represents a Boolean Query, providing
|
||||||
* various methods for combining other Query instances using boolean operators.
|
* various methods for combining other Query instances using boolean operators.
|
||||||
* @param String name of the field
|
* @param String name of the field
|
||||||
* @param String query string
|
* @param String query string
|
||||||
* @return Object BooleanQuery object
|
* @returns Object BooleanQuery object
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends helma.Search.Query
|
* @extends helma.Search.Query
|
||||||
*/
|
*/
|
||||||
helma.Search.BooleanQuery = function(field, str, clause, analyzer) {
|
helma.Search.BooleanQuery = function(field, str, clause, analyzer) {
|
||||||
|
/**
|
||||||
|
* Contains the wrapped BooleanQuery instance
|
||||||
|
* @type org.apache.lucene.search.BooleanQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.BooleanQuery();
|
this.query = new Packages.org.apache.lucene.search.BooleanQuery();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -846,7 +883,7 @@ helma.Search.BooleanQuery.prototype = new helma.Search.Query;
|
||||||
* addTerm("fieldname", "querystring", "and")
|
* addTerm("fieldname", "querystring", "and")
|
||||||
* addTerm("fieldname", "querystring", helma.Search.getAnalyzer("de"))
|
* addTerm("fieldname", "querystring", helma.Search.getAnalyzer("de"))
|
||||||
* addTerm("fieldname", "querystring", "not", helma.Search.getAnalyzer("simple"))</pre>
|
* addTerm("fieldname", "querystring", "not", helma.Search.getAnalyzer("simple"))</pre>
|
||||||
* @param {String | Array} field Either a String or an Array containing Strings
|
* @param {String|Array} field Either a String or an Array containing Strings
|
||||||
* that determine the index field(s) to match
|
* that determine the index field(s) to match
|
||||||
* @param {String} str Query string to match
|
* @param {String} str Query string to match
|
||||||
* @param {String} clause Boolean clause ("or", "not" or "and", default is "and")
|
* @param {String} clause Boolean clause ("or", "not" or "and", default is "and")
|
||||||
|
@ -900,16 +937,20 @@ helma.Search.BooleanQuery.prototype.addQuery = function(q, clause) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new PhraseQuery instance that wraps a lucene Phrase
|
* Constructs a new helma.Search.PhraseQuery instance that wraps
|
||||||
* Query object.
|
* a Lucene Phrase Query object.
|
||||||
* @class Instances of this class represent a phrase query.
|
* @class Instances of this class represent a phrase query.
|
||||||
* @param {String} field The name of the field
|
* @param {String} field The name of the field
|
||||||
* @param {String} str The phrase query string
|
* @param {String} str The phrase query string
|
||||||
* @return A newly created PhraseQuery instance
|
* @returns A newly created PhraseQuery instance
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends helma.Search.Query
|
* @extends helma.Search.Query
|
||||||
*/
|
*/
|
||||||
helma.Search.PhraseQuery = function(field, str) {
|
helma.Search.PhraseQuery = function(field, str) {
|
||||||
|
/**
|
||||||
|
* Contains the wrapped PhraseQuery instance
|
||||||
|
* @type org.apache.lucene.search.PhraseQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.PhraseQuery();
|
this.query = new Packages.org.apache.lucene.search.PhraseQuery();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -929,14 +970,14 @@ helma.Search.PhraseQuery = function(field, str) {
|
||||||
helma.Search.PhraseQuery.prototype = new helma.Search.Query;
|
helma.Search.PhraseQuery.prototype = new helma.Search.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new RangeQuery instance.
|
* Constructs a new helma.Search.RangeQuery instance.
|
||||||
* @class Instances of this class represent a range
|
* @class Instances of this class represent a range
|
||||||
* query
|
* query, wrapping a Lucene RangeQuery instance.
|
||||||
* @param {String} field The name of the field
|
* @param {String} field The name of the field
|
||||||
* @param {String} from The minimum value to match (can be null)
|
* @param {String} from The minimum value to match (can be null)
|
||||||
* @param {String} to The maximum value to match (can be null)
|
* @param {String} to The maximum value to match (can be null)
|
||||||
* @param {Boolean} inclusive If true the given min/max values are included
|
* @param {Boolean} inclusive If true the given min/max values are included
|
||||||
* @return A newly created RangeQuery instance
|
* @returns A newly created RangeQuery instance
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends helma.Search.Query
|
* @extends helma.Search.Query
|
||||||
*/
|
*/
|
||||||
|
@ -947,66 +988,83 @@ helma.Search.RangeQuery = function(field, from, to, inclusive) {
|
||||||
inclusive = true;
|
inclusive = true;
|
||||||
var t1 = from ? new Packages.org.apache.lucene.index.Term(field, from) : null;
|
var t1 = from ? new Packages.org.apache.lucene.index.Term(field, from) : null;
|
||||||
var t2 = to ? new Packages.org.apache.lucene.index.Term(field, to) : null;
|
var t2 = to ? new Packages.org.apache.lucene.index.Term(field, to) : null;
|
||||||
|
/**
|
||||||
|
* Contains the wrapped RangeQuery instance
|
||||||
|
* @type org.apache.lucene.search.RangeQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.RangeQuery(t1, t2, inclusive);
|
this.query = new Packages.org.apache.lucene.search.RangeQuery(t1, t2, inclusive);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
helma.Search.RangeQuery.prototype = new helma.Search.Query;
|
helma.Search.RangeQuery.prototype = new helma.Search.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new FuzzyQuery instance
|
* Constructs a new helma.Search.FuzzyQuery instance.
|
||||||
* @class Instances of this class represent a fuzzy query
|
* @class Instances of this class represent a fuzzy query
|
||||||
* @param {String} field The name of the field
|
* @param {String} field The name of the field
|
||||||
* @param {String} str The query string to match
|
* @param {String} str The query string to match
|
||||||
* @return A newly created FuzzyQuery instance
|
* @returns A newly created FuzzyQuery instance
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends helma.Search.Query
|
* @extends helma.Search.Query
|
||||||
*/
|
*/
|
||||||
helma.Search.FuzzyQuery = function(field, str) {
|
helma.Search.FuzzyQuery = function(field, str) {
|
||||||
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
||||||
|
/**
|
||||||
|
* Contains the wrapped FuzzyQuery instance
|
||||||
|
* @type org.apache.lucene.search.FuzzyQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.FuzzyQuery(t);
|
this.query = new Packages.org.apache.lucene.search.FuzzyQuery(t);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
helma.Search.FuzzyQuery.prototype = new helma.Search.Query;
|
helma.Search.FuzzyQuery.prototype = new helma.Search.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new PrefixQuery instance.
|
* Constructs a new helma.Search.PrefixQuery instance.
|
||||||
* @class Instances of this class represent a prefix query
|
* @class Instances of this class represent a prefix query
|
||||||
* @param {String} field The name of the field
|
* @param {String} field The name of the field
|
||||||
* @param {String} str The query string to match
|
* @param {String} str The query string to match
|
||||||
* @return A newly created PrefixQuery instance
|
* @returns A newly created PrefixQuery instance
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends helma.Search.Query
|
* @extends helma.Search.Query
|
||||||
*/
|
*/
|
||||||
helma.Search.PrefixQuery = function(field, str) {
|
helma.Search.PrefixQuery = function(field, str) {
|
||||||
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
||||||
|
/**
|
||||||
|
* Contains the wrapped PrefixQuery instance
|
||||||
|
* @type org.apache.lucene.search.PrefixQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.PrefixQuery(t);
|
this.query = new Packages.org.apache.lucene.search.PrefixQuery(t);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
helma.Search.PrefixQuery.prototype = new helma.Search.Query;
|
helma.Search.PrefixQuery.prototype = new helma.Search.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new WildcardQuery instance.
|
* Constructs a new helma.Search.WildcardQuery instance.
|
||||||
* @class Instances of this class represent a wildcard query.
|
* @class Instances of this class represent a wildcard query.
|
||||||
* @param {String} field The name of the field
|
* @param {String} field The name of the field
|
||||||
* @param {String} str The query string to match
|
* @param {String} str The query string to match
|
||||||
* @return A newly created WildcardQuery instance
|
* @returns A newly created WildcardQuery instance
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends helma.Search.Query
|
* @extends helma.Search.Query
|
||||||
*/
|
*/
|
||||||
helma.Search.WildcardQuery = function(field, str) {
|
helma.Search.WildcardQuery = function(field, str) {
|
||||||
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
var t = new Packages.org.apache.lucene.index.Term(field, str);
|
||||||
|
/**
|
||||||
|
* Contains the wrapped WildcardQuery instance
|
||||||
|
* @type org.apache.lucene.search.WildcardQuery
|
||||||
|
*/
|
||||||
this.query = new Packages.org.apache.lucene.search.WildcardQuery(t);
|
this.query = new Packages.org.apache.lucene.search.WildcardQuery(t);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
helma.Search.WildcardQuery.prototype = new helma.Search.Query;
|
helma.Search.WildcardQuery.prototype = new helma.Search.Query;
|
||||||
|
|
||||||
|
|
||||||
/****************
|
/***************************
|
||||||
* DOCUMENT *
|
***** D O C U M E N T *****
|
||||||
****************/
|
***************************/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new instance of helma.Search.Document.
|
||||||
* @class Instances of this class represent a single
|
* @class Instances of this class represent a single
|
||||||
* index document. This class provides various methods for
|
* index document. This class provides various methods for
|
||||||
* adding content to such documents.
|
* adding content to such documents.
|
||||||
|
@ -1020,7 +1078,7 @@ helma.Search.Document = function(document) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the wrapped Lucene Document object
|
* Returns the wrapped Lucene Document object
|
||||||
* @return The wrapped Document object
|
* @returns The wrapped Document object
|
||||||
* @type org.apache.lucene.document.Document
|
* @type org.apache.lucene.document.Document
|
||||||
*/
|
*/
|
||||||
this.getDocument = function() {
|
this.getDocument = function() {
|
||||||
|
@ -1036,9 +1094,9 @@ helma.Search.Document = function(document) {
|
||||||
* @param {String} value The value of the field
|
* @param {String} value The value of the field
|
||||||
* @param {Object} param Optional parameter object containing the following properties:
|
* @param {Object} param Optional parameter object containing the following properties:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>.store (Boolean) defaults to true</li>
|
* <li><code>store</code> (Boolean) defaults to true</li>
|
||||||
* <li>.index (Boolean) defaults to true</li>
|
* <li><code>index</code> (Boolean) defaults to true</li>
|
||||||
* <li>.tokenize (Boolean) defaults to true</li>
|
* <li><code>tokenize</code> (Boolean) defaults to true</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
helma.Search.Document.prototype.addField = function(name, value, param) {
|
helma.Search.Document.prototype.addField = function(name, value, param) {
|
||||||
|
@ -1065,16 +1123,17 @@ helma.Search.Document.prototype.addField = function(name, value, param) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single document field.
|
* Returns a single document field containing a value other than
|
||||||
|
* a date object, for which you should use {@link #getDateField}.
|
||||||
* @param {String} name The name of the field in this document object.
|
* @param {String} name The name of the field in this document object.
|
||||||
* @return An object containing the following properties:
|
* @returns An object containing the following properties:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>.name (String) The name of the field</li>
|
* <li><code>name</code> (String) The name of the field</li>
|
||||||
* <li>.boost (Int) The boost factor</li>
|
* <li><code>boost</code> (Int) The boost factor</li>
|
||||||
* <li>.indexed (Boolean) True if the field is indexed, false otherwise</li>
|
* <li><code>indexed</code> (Boolean) True if the field is indexed, false otherwise</li>
|
||||||
* <li>.stored (Boolean) True if the field is stored, false otherwise</li>
|
* <li><code>stored</code> (Boolean) True if the field is stored, false otherwise</li>
|
||||||
* <li>.tokenized (Boolean) True if the field is tokenized, false otherwise</li>
|
* <li><code>tokenized</code> (Boolean) True if the field is tokenized, false otherwise</li>
|
||||||
* <li>.value (String) The value of the field</li>
|
* <li><code>value</code> (String) The value of the field</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @type Object
|
* @type Object
|
||||||
*/
|
*/
|
||||||
|
@ -1093,17 +1152,18 @@ helma.Search.Document.prototype.getField = function(name) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of a single document and converts the value to
|
* Returns the value of a single document field converted into a
|
||||||
* a Date object.
|
* Date object. For retrieving a value without this conversion
|
||||||
|
* see {@link #getField}.
|
||||||
* @param {String} name The name of the field in this document object.
|
* @param {String} name The name of the field in this document object.
|
||||||
* @return An object containing the following properties:
|
* @returns An object containing the following properties:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>.name (String) The name of the field</li>
|
* <li><code>name</code> (String) The name of the field</li>
|
||||||
* <li>.boost (Int) The boost factor</li>
|
* <li><code>boost</code> (Int) The boost factor</li>
|
||||||
* <li>.indexed (Boolean) True if the field is indexed, false otherwise</li>
|
* <li><code>indexed</code> (Boolean) True if the field is indexed, false otherwise</li>
|
||||||
* <li>.stored (Boolean) True if the field is stored, false otherwise</li>
|
* <li><code>stored</code> (Boolean) True if the field is stored, false otherwise</li>
|
||||||
* <li>.tokenized (Boolean) True if the field is tokenized, false otherwise</li>
|
* <li><code>tokenized</code> (Boolean) True if the field is tokenized, false otherwise</li>
|
||||||
* <li>.value (String) The value of the field as Date</li>
|
* <li><code>value</code> (String) The value of the field as Date</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @type Object
|
* @type Object
|
||||||
* @see #getField
|
* @see #getField
|
||||||
|
@ -1119,7 +1179,7 @@ helma.Search.Document.prototype.getDateField = function(name) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the fields of a document object.
|
* Returns the fields of a document object.
|
||||||
* @return An array containing all fields in this document object.
|
* @returns An array containing all fields in this document object.
|
||||||
* @type Array
|
* @type Array
|
||||||
*/
|
*/
|
||||||
helma.Search.Document.prototype.getFields = function() {
|
helma.Search.Document.prototype.getFields = function() {
|
||||||
|
@ -1133,7 +1193,7 @@ helma.Search.Document.prototype.getFields = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the boost factor of a document.
|
* Returns the boost factor of a document.
|
||||||
* @return The boost factor of a document
|
* @returns The boost factor of a document
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
helma.Search.Document.prototype.getBoost = function() {
|
helma.Search.Document.prototype.getBoost = function() {
|
||||||
|
@ -1155,11 +1215,6 @@ helma.Search.Document.prototype.toString = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***************************
|
|
||||||
* HELMA LIBRARY STUFF *
|
|
||||||
***************************/
|
|
||||||
|
|
||||||
|
|
||||||
helma.lib = "Search";
|
helma.lib = "Search";
|
||||||
helma.dontEnum(helma.lib);
|
helma.dontEnum(helma.lib);
|
||||||
for (var i in helma[helma.lib])
|
for (var i in helma[helma.lib])
|
||||||
|
|
Loading…
Add table
Reference in a new issue