From fe74d6e0adc04bd62c1a649c9320c55e5a10c9dc Mon Sep 17 00:00:00 2001 From: grob Date: Mon, 13 Nov 2006 16:56:45 +0000 Subject: [PATCH] * changed signature of addDocuments() - it's now possible to specify an optional mergeFactor * bugfix in getField(): don't try to convert the string value into a date, since this possibly does the conversion even if it's not intended (it can happen that an id is converted into a date). therefor re-introduced the method getDateField() --- helma/Search.js | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/helma/Search.js b/helma/Search.js index 6a118fa9..c694bbf7 100644 --- a/helma/Search.js +++ b/helma/Search.js @@ -17,9 +17,9 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // -// $Revision: 1.4 $ +// $Revision: 1.5 $ // $Author: robert $ -// $Date: 2006/09/29 13:49:40 $ +// $Date: 2006/10/23 18:56:36 $ // @@ -487,9 +487,12 @@ helma.Search.Index.prototype.addDocument = function(doc) { * @param {java.util.Hashtable | java.util.Vector | Array} docs * The documents to add to the index. */ -helma.Search.Index.prototype.addDocuments = function(docs) { +helma.Search.Index.prototype.addDocuments = function(docs, mergeFactor) { try { var modifier = this.getModifier(); + if (mergeFactor) { + modifier.setMergeFactor(mergeFactor); + } if (docs instanceof java.util.Hashtable || docs instanceof java.util.Vector) { var e = docs.elements(); while (e.hasMoreElements()) { @@ -1083,18 +1086,37 @@ helma.Search.Document.prototype.getField = function(name) { indexed: f.isIndexed(), stored: f.isStored(), tokenized: f.isTokenized(), - value: null}; - try { - var pkg = Packages.org.apache.lucene.document.DateTools; - result.value = pkg.stringToDate(f.stringValue()); - } catch (e) { - result.value = f.stringValue(); - } + value: f.stringValue()}; return result; } return null; }; +/** + * Returns the value of a single document and converts the value to + * a Date object. + * @param {String} name The name of the field in this document object. + * @return An object containing the following properties: + * + * @type Object + * @see #getField + */ +helma.Search.Document.prototype.getDateField = function(name) { + var result = this.getField(name); + if (result != null) { + // convert value to Date object + result.value = Packages.org.apache.lucene.document.DateTools.stringToDate(result.value); + } + return result; +}; + /** * Returns the fields of a document object. * @return An array containing all fields in this document object.