例: FTSearchRange method

次のエージェントは、現在のデータベースから、ユーザーの定義した文字列を含むすべての文書を 8 グループに分けて返します。

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      // Update full-text index
      db.updateFTIndex(true);
      // Get query and put in quotes
      String query = agentContext.getCurrentAgent().getComment();
      if (query.length() != 0) {
        query = "¥"" + query + "¥"";// Get the first 8 documents that match the query
        int start = 1;
        DocumentCollection dc = db.FTSearchRange(query, 8,
          Database.FT_SCORES, Database.FT_STEMS, start);
        while (dc.getCount() > 0) {
          // Display subject for documents matching query
          System.out.println("Search results "
            + start + " - " + (start - 1 + dc.getCount()));
          Document doc = dc.getFirstDocument();
          while (doc != null) {
            System.out.println
              ("¥t" + doc.getItemValueString("Subject"));
            doc = dc.getNextDocument(doc);
          }
          // Get next 8 documents that match the query
          start = start + 8;
          dc = db.FTSearchRange(query, 8,
            Database.FT_SCORES, Database.FT_STEMS, start);
        }
      }

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}