I have a simple web application with two entities:
User can create and read own States. I created full text search (elasticsearch) for States but my search returns me all States, not only created by logged user. I tried something like this but it doesn't work:
public Page<StatusDTO> search(String query, Pageable pageable) {
log.debug("Request to search for a page of Statuses for query {}", query);
String login = SecurityUtils.getCurrentUserLogin();
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(queryStringQuery(query))
.withFilter(boolQuery().filter(termQuery("ownerUser : login", login)))
.build();
Page<Status> result = statusSearchRepository.search(searchQuery.getQuery(), pageable);
return result.map(statusMapper::toDto);
}
你能试一下吗
.withFilter(boolQuery().filter(termQuery("ownerUser.login", login)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.