diff --git a/helma/Search.js b/helma/Search.js index 6e8aff37..e0772eae 100644 --- a/helma/Search.js +++ b/helma/Search.js @@ -395,6 +395,25 @@ helma.Search.Index.prototype.size = function() { return; }; +/** + * Returns the number of documents with the given field name and value. + * @param {String} fieldName The name of the field + * @param {String} fieldValue The value of the field + * @returns The number of documents + * @type Number + */ +helma.Search.Index.prototype.count = function(fieldName, fieldValue) { + try { + var reader = this.getReader(); + var term = new Packages.org.apache.lucene.index.Term(fieldName, fieldValue); + return reader.docFreq(term); + } finally { + if (reader !== null) { + reader.close(); + } + } +}; + /** * Optimizes the underlying index. */ diff --git a/helma/lucene-analyzers.jar b/helma/lucene-analyzers.jar index 7e37b731..6bd3d31e 100644 Binary files a/helma/lucene-analyzers.jar and b/helma/lucene-analyzers.jar differ diff --git a/helma/lucene-core.jar b/helma/lucene-core.jar index 2469481c..23c077e2 100644 Binary files a/helma/lucene-core.jar and b/helma/lucene-core.jar differ