code: public static void useResource(String host, int port, String user, String password, Authentication authType)
      throws IOException, ParserConfigurationException
    {
      // create the client
      DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);
  
      // create the search collector
      SearchCollector collector = new SearchCollector(client);
  
      // search for documents to collect
      CollectorResults results = collector.collect(
        "neighborhood industry:\"Real Estate\"", 1, OPTIONS_NAME
      );
  
      System.out.println();
      System.out.println("search results:");
      System.out.println(results.getSearchResult(new StringHandle()).get());
  
      // iterate over the collected documents
      StringHandle resultHandle = new StringHandle();
      for (int i=1; results.hasNext(); i++) {
        System.out.println();
        System.out.println("matched document "+i+":");
        System.out.println(results.next(resultHandle).get());
      }
  
      // release the iterator resources
      results.close();
  
      // release the client
      client.release();
    }
docs: use the resource manager