Skip to content

Instantly share code, notes, and snippets.

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));
<dependency>
<groupId> org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>LATEST</version>
</dependency>
@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/

@Configuration
public class ElasticsearchConfig {
@Value("${elasticsearch.host}")
private String elasticsearchHost;
@Bean(destroyMethod = "close")
public RestHighLevelClient client() {
RestHighLevelClient client = new RestHighLevelClient(
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("/{id}")
public ProfileDocument findById(@PathVariable String id) throws Exception {
return service.findById(id);
}
@RestController("/api/v1/profiles")
public class ProfileController {
private ProfileService service;
@Autowired
public ProfileController(ProfileService service) {
this.service = service;
}
@GetMapping(value = "/search")
public List<ProfileDocument> search(
@RequestParam(value = "technology") String technology)
throws Exception {
return service.searchByTechnology(technology);
}
@DeleteMapping("/{id}")
public String deleteProfile(@PathVariable String id)
throws Exception {
return service.deleteProfileDocument(id);
}
@PutMapping
public ResponseEntity updateProfile(@RequestBody ProfileDocument document) throws Exception {
return new ResponseEntity(service.updateProfile(document), HttpStatus.CREATED);
}