code: public I_CmsDocumentFactory getDocumentFactory(CmsResource resource) {
  
          // first get the MIME type of the resource
          String mimeType = OpenCms.getResourceManager().getMimeType(resource.getRootPath(), null, "unknown");
          String resourceType = null;
          try {
              resourceType = OpenCms.getResourceManager().getResourceType(resource.getTypeId()).getTypeName();
          } catch (CmsLoaderException e) {
              // ignore, unknown resource type, resource can not be indexed
              LOG.info(e.getLocalizedMessage(), e);
          }
          return getDocumentFactory(resourceType, mimeType);
      }
docs: Returns a lucene document factory for given resource.<p>
  
  The type of the document factory is selected by the type of the resource
  and the MIME type of the resource content, according to the configuration in <code>opencms-search.xml</code>.<p>
  
  @param resource a cms resource
  @return a lucene document factory or null