Skip to content

Instantly share code, notes, and snippets.

@javajack
Forked from spati-java/ProfileService.java
Created July 28, 2020 19:54
Show Gist options
  • Save javajack/09956bfdbad8487aaaa39ffb15ca3e12 to your computer and use it in GitHub Desktop.
Save javajack/09956bfdbad8487aaaa39ffb15ca3e12 to your computer and use it in GitHub Desktop.
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));
searchSourceBuilder.query(QueryBuilders
.nestedQuery("technologies",
queryBuilder,
ScoreMode.Avg));
searchRequest.source(searchSourceBuilder);
SearchResponse response =
client.search(searchRequest, RequestOptions.DEFAULT);
return getSearchResult(response);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment