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


  • Parameter {String:
    | Array} field Either a String or an Array containing Strings that determine the index field(s) to match
  • Parameter {String}:
    str Query string to match
  • Parameter {String}:
    clause Boolean clause ("or", "not" or "and", default is "and")
  • Parameter {org.apache.lucene.analysis.Analyzer}:
    analyzer An analyzer to use
Sourcecode in /home/hannes/helma/modules/helma/Search.js:
855:   helma.Search.BooleanQuery.prototype.addTerm = function(field, str, clause, analyzer) {
856:       if (arguments.length == 3 && arguments[2] instanceof Packages.org.apache.lucene.analysis.Analyzer) {
857:           analyzer = arguments[2];
858:           clause = "or";
859:       }
860:       if (!analyzer) {
861:           analyzer = helma.Search.getAnalyzer();
862:       }
863:   
864:      var q;
865:      if (field instanceof Array) {
866:          q = Packages.org.apache.lucene.queryParser.MultiFieldQueryParser.parse(str, field, analyzer);
867:      } else {
868:          q = Packages.org.apache.lucene.queryParser.QueryParser.parse(str, field, analyzer);
869:      }
870:      switch (clause) {
871:          case "or":
872:              this.getQuery().add(q, false, false);
873:              break;
874:          case "not":
875:              this.getQuery().add(q, false, true);
876:              break;
877:          default:
878:              this.getQuery().add(q, true, false);
879:      }
880:      return;
881:  }