Package com.mindstore.backend.controller
Class OpenSearchController
java.lang.Object
com.mindstore.backend.controller.OpenSearchController
REST controller for texts
-
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchController(TextIndexService textIndexService, JwtService jwtService, TextSearchService textSearchService) controller class for opensearch -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<TextDocument> createTextIndex(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 entriesorg.springframework.http.ResponseEntity<Object> function: deletes text documentsgetAllTextIndexes(String searchAfter, int size) function: used to return all Text documents availablegetAllTextIndexesWithTag(List<String> tags, String searchAfter, 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
-
Constructor Details
-
OpenSearchController
public OpenSearchController(TextIndexService textIndexService, JwtService jwtService, TextSearchService textSearchService) controller class for opensearch- Parameters:
textIndexService- service class for basic text document operationsjwtService- jwt service classtextSearchService- 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 createdAtsize- - 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 searchedsearchAfter- - searchAfter string that references the createdAtsize- - 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
-