docs: private void indexFile(FileAbstractModel fileAbstractModel, ScanStatistic stats, String dirname, InputStream inputStream,
                             long filesize) throws Exception {
          final String filename = fileAbstractModel.getName();
          final LocalDateTime created = fileAbstractModel.getCreationDate();
          final LocalDateTime lastModified = fileAbstractModel.getLastModifiedDate();
          final LocalDateTime lastAccessed = fileAbstractModel.getAccessDate();
          final String extension = fileAbstractModel.getExtension();
          final long size = fileAbstractModel.getSize();
  
          logger.debug("fetching content from [{}],[{}]", dirname, filename);
  
          try {
              // Create the Doc object (only needed when we have add_as_inner_object: true (default) or when we don't index json or xml)
              if (fsSettings.getFs().isAddAsInnerObject() || (!fsSettings.getFs().isJsonSupport() && !fsSettings.getFs().isXmlSupport())) {
  
                  String fullFilename = new File(dirname, filename).toString();
  
                  Doc doc = new Doc();
  
                  // File
                  doc.getFile().setFilename(filename);
                  doc.getFile().setCreated(localDateTimeToDate(created));
                  doc.getFile().setLastModified(localDateTimeToDate(lastModified));
                  doc.getFile().setLastAccessed(localDateTimeToDate(lastAccessed));
                  doc.getFile().setIndexingDate(localDateTimeToDate(LocalDateTime.now()));
                  doc.getFile().setUrl("file://" + fullFilename);
                  doc.getFile().setExtension(extension);
                  if (fsSettings.getFs().isAddFilesize()) {
                      doc.getFile().setFilesize(size);
                  }
                  // File
  
                  // Path
                  // Encoded version of the dir this file belongs to
                  doc.getPath().setRoot(SignTool.sign(dirname));
                  // The virtual URL (not including the initial root dir)
                  doc.getPath().setVirtual(computeVirtualPathName(stats.getRootPath(), fullFilename));
                  // The real and complete filename
                  doc.getPath().setReal(fullFilename);
                  // Path
  
                  // Attributes
                  if (fsSettings.getFs().isAttributesSupport()) {
                      doc.setAttributes(new Attributes());
                      doc.getAttributes().setOwner(fileAbstractModel.getOwner());
                      doc.getAttributes().setGroup(fileAbstractModel.getGroup());
                      if (fileAbstractModel.getPermissions() >= 0) {
                          doc.getAttributes().setPermissions(fileAbstractModel.getPermissions());
                      }
                  }
                  // Attributes
  
                  // If needed, we generate the content in addition to metadata
                  if (fsSettings.getFs().isJsonSupport()) {
                      // https://github.com/dadoonet/fscrawler/issues/5 : Support JSon files
                      doc.setObject(DocParser.asMap(read(inputStream)));
                  } else if (fsSettings.getFs().isXmlSupport()) {
                      // https://github.com/dadoonet/fscrawler/issues/185 : Support Xml files
                      doc.setObject(XmlDocParser.generateMap(inputStream));
                  } else {
                      // Extracting content with Tika
                      TikaDocParser.generate(fsSettings, inputStream, filename, fullFilename, doc, messageDigest, filesize);
                  }
  
                  // We index the data structure
                  if (isIndexable(doc.getContent(), fsSettings.getFs().getFilters())) {
                      esIndex(fsSettings.getElasticsearch().getIndex(),
                              generateIdFromFilename(filename, dirname),
                              DocParser.toJson(doc),
                              fsSettings.getElasticsearch().getPipeline());
                  } else {
                      logger.debug("We ignore file [{}] because it does not match all the patterns {}", filename,
                              fsSettings.getFs().getFilters());
                  }
              } else {
                  if (fsSettings.getFs().isJsonSupport()) {
                      // We index the json content directly
                      esIndex(fsSettings.getElasticsearch().getIndex(),
                              generateIdFromFilename(filename, dirname),
                              read(inputStream),
                              fsSettings.getElasticsearch().getPipeline());
                  } else if (fsSettings.getFs().isXmlSupport()) {
                      // We index the xml content directly
                      esIndex(fsSettings.getElasticsearch().getIndex(),
                              generateIdFromFilename(filename, dirname),
                              XmlDocParser.generate(inputStream),
                              fsSettings.getElasticsearch().getPipeline());
                  }
              }
          } finally {
              // Let's close the stream
              if (inputStream != null) {
                  inputStream.close();
              }
          }
      }