Class SearchController

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

@RestController @RequestMapping("/api/search") public class SearchController extends Object
REST controller for searches within text-index
  • Constructor Details

    • SearchController

      public SearchController(TextSearchService textSearchService, SearchHistoryService searchHistoryService)
      search controller constructor
      Parameters:
      textSearchService - service class for search functions
      searchHistoryService - service class or search history functions
  • Method Details

    • search

      @GetMapping public SearchResultDto<TextDocument> search(@RequestParam String query, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="") String searchAfter, Principal principal)
      Searches through all available TextDocuments based on the query parameter. Results are paginated and returned in a SearchResultDto. Additionally, the query is saved to the search history.
      Parameters:
      query - the search term entered by the user
      page - the zero-based page index for pagination (default is 0)
      size - the number of items per page (default is 10)
      searchAfter - the string for the next search page
      principal - the currently authenticated user (used for audit or filtering if needed)
      Returns:
      a SearchResultDto containing the paginated list of matching TextDocuments
    • searchThroughTags

      @GetMapping("/tag-search") public SearchResultDto<TextDocument> searchThroughTags(@RequestParam String query, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="") String searchAfter, @RequestParam List<String> tags, Principal principal)
      function: search controller endpoint for search inside tagged texts
      Parameters:
      query - the search term entered by the user
      page - the zero-based page index for pagination (default is 0)
      size - the number of items per page (default is 10)
      searchAfter - the string for the next search page
      tags - the tags that we filter the texts with
      principal - the currently authenticated user (used for audit or filtering if needed)
      Returns:
      a SearchResultDto containing the paginated list of matching TextDocuments
    • autocompleteString

      @GetMapping("/autocomplete") public List<String> autocompleteString(@RequestParam String prefix) throws IOException
      function: endpoint for autocompletion within search
      Parameters:
      prefix - - string we are searching for, for example "do" will suggest "docker"
      Returns:
      List of strings that match query
      Throws:
      IOException - when search fails
    • test

      @GetMapping("/test") public org.springframework.http.ResponseEntity<String> test()
      function: used to test the SearchController and debugging
      Returns:
      ok ---> if successfull
    • getSearchHistory

      @GetMapping("/history") public org.springframework.http.ResponseEntity<List<String>> getSearchHistory(Principal principal)
      function: get the recent searches that were made by the user
      Parameters:
      principal - the currently authenticated user
      Returns:
      a List of strings with the searches
    • getTagList

      @GetMapping("/tags") public Category[] getTagList()
      function: used to get all the available values the CATEGORY enum can have
      Returns:
      Array of Category enum
    • searchThroughTime

      @GetMapping("/time") public SearchResultDto<TextDocument> searchThroughTime(@RequestParam String query, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="") String searchAfter, @RequestParam(required=false) String dateFrom, @RequestParam(required=false) String dateTo, Principal principal)
      Searches through all available TextDocuments based on the query parameter. Results are paginated and returned in a SearchResultDto. Additionally, the query is saved to the search history.
      Parameters:
      query - the search term entered by the user
      page - the zero-based page index for pagination (default is 0)
      size - the number of items per page (default is 10)
      searchAfter - the string for the next search page
      dateFrom - the date we are querying from
      dateTo - the date we are querying to
      principal - the currently authenticated user (used for audit or filtering if needed)
      Returns:
      a SearchResultDto containing the paginated list of matching TextDocuments
    • searchCommandList

      @GetMapping("/command-search") public SearchResultDto<TextDocument> searchCommandList(@RequestParam String command, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="") String searchAfter, Principal principal)
      Searches through all available TextDocuments based on the query parameter. Results are paginated and returned in a SearchResultDto. Additionally, the query is saved to the search history.
      Parameters:
      command - the command entered by the user
      page - the zero-based page index for pagination (default is 0)
      size - the number of items per page (default is 10)
      searchAfter - the string for the next search page
      principal - the currently authenticated user (used for audit or filtering if needed)
      Returns:
      a SearchResultDto containing the paginated list of matching TextDocuments
    • searchHighlighted

      @GetMapping("/highlight") public SearchResultDto<SearchHitDto<TextDocument>> searchHighlighted(@RequestParam String query, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size, @RequestParam(defaultValue="") String searchAfter, Principal principal)
      Searches through all available TextDocuments based on the query parameter. Results are paginated and returned in a SearchResultDto. Additionally, the query is saved to the search history.
      Parameters:
      query - the search term entered by the user
      page - the zero-based page index for pagination (default is 0)
      size - the number of items per page (default is 10)
      searchAfter - the string for the next search page
      principal - the currently authenticated user (used for audit or filtering if needed)
      Returns:
      a SearchResultDto containing the paginated list of matching TextDocuments and a section of highlighted results