Class OpenSearchController

java.lang.Object
com.mindstore.backend.controller.OpenSearchController

@RestController @RequestMapping("/text-index") public class OpenSearchController extends Object
REST controller for texts
  • Constructor Details

    • OpenSearchController

      public OpenSearchController(TextIndexService textIndexService, JwtService jwtService, TextSearchService textSearchService)
      controller class for opensearch
      Parameters:
      textIndexService - service class for basic text document operations
      jwtService - jwt service class
      textSearchService - service class for text seearches
  • Method Details

    • getAllTextIndexes

      @GetMapping("/all") public SearchResultDto<TextDocument> getAllTextIndexes(@RequestParam(defaultValue="") String searchAfter, @RequestParam(defaultValue="10") int size)
      function: used to return all Text documents available
      Parameters:
      searchAfter - - searchAfter string that references the createdAt
      size - - the size of the result to be fetched
      Returns:
      a SearchResultDto with the TextDocuments
    • getAllTextIndexesWithTag

      @GetMapping("/all/tags") public SearchResultDto<TextDocument> getAllTextIndexesWithTag(@RequestParam List<String> tags, @RequestParam(defaultValue="") String searchAfter, @RequestParam(defaultValue="10") int size)
      function: used to get all text documents that contain a specific tag or a list of tags, used in the frontend to filter for specific tags
      Parameters:
      tags - that are searched
      searchAfter - - searchAfter string that references the createdAt
      size - - the size of the result to be fetched
      Returns:
      a SearchResultDto with the text documents
    • createTextIndex

      @PostMapping("/create") public org.springframework.http.ResponseEntity<TextDocument> createTextIndex(@RequestBody TextDocument textDocument, jakarta.servlet.http.HttpServletResponse response)
      function: used to create new text documents, used in the frontend so that the user can add new entries
      Parameters:
      textDocument - with title, content, taglist, etc.
      response - - the extended response
      Returns:
      201 CREATED --> if successfull
    • deleteTextDocument

      @DeleteMapping("/delete") public org.springframework.http.ResponseEntity<Object> deleteTextDocument(@RequestParam Integer id) throws IOException
      function: deletes text documents
      Parameters:
      id - - id of the document we want to delete
      Returns:
      Status OK when successfull
      Throws:
      IOException - when deletion fails