Global.helma.Search.Searcher.prototype.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.

  • Parameter {helma.Search.Query}:
    query The query to use for searching
  • Parameter {helma.Search.QueryFilter}:
    filter An optional query filter for filtering the results.
  • Returns
    The number of hits.
Sourcecode in /home/hannes/helma/modules/helma/Search.js:
646:   helma.Search.Searcher.prototype.search = function(query, filter) {
647:       var PKG = Packages.org.apache.lucene.search;
648:       var hits;
649:       if (this.sortFields != null && this.sortFields.size() > 0) {
650:           var arr = java.lang.reflect.Array.newInstance(PKG.SortField, this.sortFields.size());
651:           var sort = PKG.Sort(this.sortFields.toArray(arr));
652:           if (filter) {
653:               hits = this.getSearcher().search(query.getQuery(), filter.getFilter(), sort);
654:           } else {
655:              hits = this.getSearcher().search(query.getQuery(), sort);
656:          }
657:      } else if (filter) {
658:          hits = this.getSearcher().search(query.getQuery(), filter.getFilter());
659:      } else {
660:          hits = this.getSearcher().search(query.getQuery());
661:      }
662:      this.hits = new helma.Search.HitCollection(hits);
663:      return this.hits.length();
664:  }