findByTitle (Query method)

Repository

Flux<Post> findPostByTitleIgnoreCase(String text);

Service

Antes

public List<PostDTO> findByTitle(String text) {
    List<PostDTO> result = repository.searchTitle(text).stream().map(x -> new PostDTO(x)).toList();
    return result;
}

Depois

public Flux<PostDTO> findByTitle(String text) {
    Flux<Post> result;

    if (text == null || text.isEmpty()) {
        result = repository.findAll();
    } else {
        result = repository.findPostByTitleIgnoreCase(text);
    }

    return result.map(PostDTO::new);
}

Controller

Antes

@GetMapping(value = "/titlesearch")
public ResponseEntity<List<PostDTO>> findByTitle(@RequestParam(value = "text", defaultValue = "") String text) throws UnsupportedEncodingException {
    text = URL.decodeParam(text);
    List<PostDTO> list = service.findByTitle(text);
    return ResponseEntity.ok(list);
}

Depois

@GetMapping(value = "/titlesearch")
public Flux<PostDTO> findByTitle(@RequestParam(value = "text", defaultValue = "") String text) throws UnsupportedEncodingException {
    text = URL.decodeParam(text);
    return service.findByTitle(text);
}

Atualizado