private List<DocumentationItemDTO> getDocumentation(
      List<Document> docs, String searchTerm, int maxResults) {
    Stream<DocumentationItem> documentationStream;
    if (searchTerm.isEmpty()) {
      documentationStream =
          documentationService.documentationForDocuments(docs, maxResults).stream();
    } else {
      documentationStream =
          documentationService.searchDocumentation(searchTerm, docs, maxResults).stream();
    }

    return documentationStream
        .map(Transformations::convertDocumentationItemToDTO)
        .collect(Collectors.toList());
  }
  @GET
  @Path("/{name}/{version}")
  @ApiOperation(
      value = "Documents by name and version",
      notes = "Documents always have a name and a version",
      response = DocumentDTO.class,
      responseContainer = "List")
  public List<DocumentDTO> documentByNameAndVersion(
      @ApiParam(value = "Name of documents to fetch", required = true) @PathParam("name")
          String name,
      @ApiParam(value = "Version of named documents", required = true) @PathParam("version")
          String version,
      @ApiParam(value = "Whether to re-index document", required = false, defaultValue = "false")
          @DefaultValue("false")
          @QueryParam("reindex")
          boolean reindex) {

    List<Document> documents = documentRepository.findDocumentsByNameAndVersion(name, version);

    if (reindex) {
      documents.stream().forEach(document -> documentationService.reindexDocument(document));
    }

    return documents
        .stream()
        .map(Transformations::convertDocumentToDTO)
        .collect(Collectors.toList());
  }
  @PUT
  @Path("/{name}/{version}")
  @Consumes(MediaType.MULTIPART_FORM_DATA)
  @ApiOperation(
      value = "Documentats by name and version",
      notes = "Documents always have a name and a version",
      response = DocumentDTO.class)
  public Response createDocument(
      @ApiParam(value = "Name of document", required = true) @PathParam("name") String name,
      @ApiParam(value = "Version of document", required = true) @PathParam("version")
          String version,
      @ApiParam(value = "DocSet tgz archive", required = true) @FormDataParam("file")
          InputStream uploadedInputStream,
      @FormDataParam("file") FormDataContentDisposition fileDetail) {

    String archivePath = String.format("%s/%s_%s.tgz", uploadDirectory, name, version);
    writeToFile(uploadedInputStream, archivePath);
    Document document = new Document(name, version);
    documentationService.installDocumentFromDocSetArchive(document, archivePath);
    return Response.status(Response.Status.OK)
        .entity(Transformations.convertDocumentToDTO(document))
        .build();
  }