Skip to content

Instantly share code, notes, and snippets.

public String updateProfile(ProfileDocument document) throws Exception {
ProfileDocument resultDocument = findById(document.getId());
UpdateRequest updateRequest = new UpdateRequest(
INDEX,
TYPE,
resultDocument.getId());
Map<String, Object> documentMapper =
@GetMapping
public List<ProfileDocument> findAll() throws Exception {
return service.findAll();
}
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);
private List<ProfileDocument> getSearchResult(SearchResponse response) {
SearchHit[] searchHit = response.getHits().getHits();
List<ProfileDocument> profileDocuments = new ArrayList<>();
if (searchHit.length > 0) {
Arrays.stream(searchHit)
.forEach(hit -> profileDocuments
@GetMapping(value = "/search")
public List<ProfileDocument> search(
@RequestParam(value = "technology") String technology)
throws Exception {
return service.searchByTechnology(technology);
}
public List<ProfileDocument> searchByTechnology(String technology) throws Exception {
SearchRequest searchRequest = new SearchRequest();
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
QueryBuilder queryBuilder = QueryBuilders
.boolQuery()
.must(QueryBuilders
.matchQuery("technologies.name", technology));
@DeleteMapping("/{id}")
public String deleteProfile(@PathVariable String id)
throws Exception {
return service.deleteProfileDocument(id);
}
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();
@spati-java
spati-java / 1_README.md
Created September 9, 2019 13:25 — forked from Daniel15/1_README.md
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/