This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GetMapping | |
public List<ProfileDocument> findAll() throws Exception { | |
return service.findAll(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String deleteProfileDocument(String id) throws Exception { | |
DeleteRequest deleteRequest = new DeleteRequest(INDEX, TYPE, id); | |
DeleteResponse response = | |
client.delete(deleteRequest, RequestOptions.DEFAULT); | |
return response | |
.getResult() | |
.name(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<ProfileDocument> findAll() throws Exception { | |
SearchRequest searchRequest = new SearchRequest(); | |
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); | |
searchSourceBuilder.query(QueryBuilders.matchAllQuery()); | |
searchRequest.source(searchSourceBuilder); | |
SearchResponse searchResponse = | |
client.search(searchRequest, RequestOptions.DEFAULT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String updateProfile(ProfileDocument document) throws Exception { | |
ProfileDocument resultDocument = findById(document.getId()); | |
UpdateRequest updateRequest = new UpdateRequest( | |
INDEX, | |
TYPE, | |
resultDocument.getId()); | |
Map<String, Object> documentMapper = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ProfileDocument findById(String id) throws Exception { | |
GetRequest getRequest = new GetRequest(INDEX, TYPE, id); | |
GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT); | |
Map<String, Object> resultMap = getResponse.getSource(); | |
return objectMapper | |
.convertValue(resultMap, ProfileDocument.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
@Slf4j | |
public class ProfileService { | |
private RestHighLevelClient client; | |
private ObjectMapper objectMapper; | |
@Autowired | |
public ProfileService(RestHighLevelClient client, ObjectMapper objectMapper) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.fasterxml.jackson.core</groupId> | |
<artifactId>jackson-databind</artifactId> | |
<version>2.9.6</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
public class ProfileDocument { | |
private String id; | |
private String firstName; | |
private String lastName; | |
private List<Technologies> technologies; | |
private List<String> emails; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elasticsearch.host=search-dev-elasticsearch-5bgsa4vpjib46bgh4cbtebsxydiq.us-east-1.es.amazonaws.com |
NewerOlder