1
votes

I'm at a bit of an impasse. I am working in Domino with xPages and I am trying to allow full text searching through a view including response documents but including the parent document for any responses that match the query in the view or data table. Currently I'm just using the search term in a view datasource, and then using that datasource in a view control, but any workable solution would be welcome. There may be additional search criteria on the parent document.

Any ideas?

1

1 Answers

1
votes

Richard, you can't directly use the view as data source, so you won't use the view control. You can use the data table or (probably better, since it gives you full layout control) the repeat control.

Run the search against the view in code:

   var v = database.getView("yourView")
   //var result = database.FTSearch(...)
   var result = v.FTSearchSorted(...) // or FTSearch
   var datasource = [];
   var parent;
   for (var doc in result) {
        addResult(doc, datasource);            
        if (doc.isResponseDoc()) {
            parent = doc.getParentDocument();
            addResult(parent, datasource);
            // Careful here - if the parent is part of the resultset on its own
            parent.recycle(); 
        }
        doc.recycle();
   }
   try {
      result.recycle();
      v.recycle();
   } catch (e) {
     // We suffer silently
   }
   return datasource;

   function addResult(doc, datasource) {
        var oneResult = {};
        //Adjust that to your needs
        oneResult.subject = doc.getItemValueString("Subject");
        oneResult.unid = doc.getUniversalId();
        datasource.push(oneResult);
   }

See the FTSearchSorted documentation. I typed the code off my head, so there might be little syntax snafus, ut you get the idea Don't return documents or Notes objects to the XPage and use recycle() wisely.