|
|
|
@ -21,6 +21,7 @@ import org.elasticsearch.client.RequestOptions; |
|
|
|
|
import org.elasticsearch.client.Requests; |
|
|
|
|
import org.elasticsearch.client.RestHighLevelClient; |
|
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder; |
|
|
|
|
import org.elasticsearch.index.query.MatchPhraseQueryBuilder; |
|
|
|
|
import org.elasticsearch.index.query.QueryBuilder; |
|
|
|
|
import org.elasticsearch.index.query.QueryBuilders; |
|
|
|
|
import org.elasticsearch.search.SearchHits; |
|
|
|
@ -138,11 +139,16 @@ public class FileSearchService { |
|
|
|
|
return PageVo.ofSearchHits(response.getHits(), param); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<String> getChildrenByDirId(String dirId) { |
|
|
|
|
DirectoryVo dir = directoryService.getById(dirId); |
|
|
|
|
return StreamUtil.as(directoryService.childrenLists(dir, ReviewStatus.SUBMITTED)).map(DirectoryVo::getId).toList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 图片检索 |
|
|
|
|
* |
|
|
|
|
* @param dirId |
|
|
|
|
* @param searchText |
|
|
|
|
* @param pageNo |
|
|
|
|
* @param pageSize |
|
|
|
|
* @return |
|
|
|
|
* @throws IOException |
|
|
|
|
*/ |
|
|
|
|
public PageVo<Object> searchImage(String dirId, String searchText, int pageNo, int pageSize) throws IOException { |
|
|
|
|
SearchRequest request = Requests.searchRequest("shandan"); |
|
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); |
|
|
|
@ -159,8 +165,9 @@ public class FileSearchService { |
|
|
|
|
} |
|
|
|
|
if (StringUtils.hasText(searchText)) { |
|
|
|
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); |
|
|
|
|
boolQuery.should(QueryBuilders.matchPhraseQuery("fileName", searchText)); |
|
|
|
|
queryBuilder.must(boolQuery); |
|
|
|
|
MatchPhraseQueryBuilder matchPhraseQuery = QueryBuilders.matchPhraseQuery("fileName", searchText); |
|
|
|
|
boolQuery.should(); |
|
|
|
|
queryBuilder.must(matchPhraseQuery); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
searchSourceBuilder.query(queryBuilder); |
|
|
|
@ -184,4 +191,10 @@ public class FileSearchService { |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
return PageVo.ofSearchHits(response.getHits(), page); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<String> getChildrenByDirId(String dirId) { |
|
|
|
|
DirectoryVo dir = directoryService.getById(dirId); |
|
|
|
|
return StreamUtil.as(directoryService.childrenLists(dir, ReviewStatus.SUBMITTED)).map(DirectoryVo::getId).toList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|