Class TextSearchService

java.lang.Object
com.mindstore.backend.service.TextSearchService

@Service public class TextSearchService extends Object
Service class for search functionalities within the text index
  • Constructor Details

    • TextSearchService

      public TextSearchService(org.opensearch.client.opensearch.OpenSearchClient client)
      text search service
      Parameters:
      client - opensearch client
  • Method Details

    • search

      public SearchResultDto<TextDocument> search(String query, int page, int size, String searchAfter)
      function: search the available TextDocuments for a specific string
      Parameters:
      query - the string we are searching for
      page - param used for pagination, page number
      size - defines how many results are returned
      searchAfter - string for the next search result page
      Returns:
      a SearchResultDto with TextDocuments that match the query
    • searchThroughTaggedTexts

      public SearchResultDto<TextDocument> searchThroughTaggedTexts(List<String> categories, String query, int page, int size, String searchAfter)
      search function for tagged texts
      Parameters:
      categories - - the list of categories that we need to filter
      query - - the user query
      page - - page for result
      size - - number of results
      searchAfter - String for pagination
      Returns:
      list of searchResultDtos
    • autocomplete

      public List<String> autocomplete(String prefix) throws IOException
      function for autocompletion results for a search
      Parameters:
      prefix - - String that we are searching for
      Returns:
      List of titles that match for that string
      Throws:
      IOException - when search fails
    • findTags

      public Category[] findTags()
      function: returns all available values of Category enum
      Returns:
      array of categories
    • findAll

      public SearchResultDto<TextDocument> findAll(String searchAfter, int size)
      function: service method that returns all available textDocuments
      Parameters:
      searchAfter - - searchAfter string
      size - - size of the results
      Returns:
      list of documents
    • findAllWithTags

      public SearchResultDto<TextDocument> findAllWithTags(List<String> categories, String searchAfter, int size)
      function that finds all texts with certain tags
      Parameters:
      categories - list of category enum strings
      searchAfter - - searchAfter string
      size - - size of the results
      Returns:
      a List with TextDocuments that match that query
    • searchWithTimeSpan

      public SearchResultDto<TextDocument> searchWithTimeSpan(String query, int page, int size, String searchAfter, String from, String to)
      function: search the available TextDocuments for a specific string
      Parameters:
      query - the string we are searching for
      page - param used for pagination, page number
      size - defines how many results are returned
      searchAfter - string for the next search result page
      from - defines the from date for the time span
      to - defines the to date for the time span
      Returns:
      a SearchResultDto with TextDocuments that match the query, filter out the search results from the time span
    • searchForCommand

      public SearchResultDto<TextDocument> searchForCommand(String command, int page, int size, String searchAfter)
      function: search the available TextDocuments for a specific string
      Parameters:
      command - the string we are searching for
      page - param used for pagination, page number
      size - defines how many results are returned
      searchAfter - string for the next search result page
      Returns:
      a SearchResultDto with TextDocuments that match the query, filter out the search results from the time span
    • searchHighlighted

      public SearchResultDto<SearchHitDto<TextDocument>> searchHighlighted(String query, int page, int size, String searchAfter)
      function: search the available TextDocuments for a specific string
      Parameters:
      query - the string we are searching for
      page - param used for pagination, page number
      size - defines how many results are returned
      searchAfter - string for the next search result page
      Returns:
      a SearchResultDto with TextDocuments that match the query, highlighted search results