|
|
@ -21,6 +21,7 @@ import org.elasticsearch.client.RequestOptions; |
|
|
|
import org.elasticsearch.client.Requests; |
|
|
|
import org.elasticsearch.client.Requests; |
|
|
|
import org.elasticsearch.client.RestHighLevelClient; |
|
|
|
import org.elasticsearch.client.RestHighLevelClient; |
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder; |
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder; |
|
|
|
|
|
|
|
import org.elasticsearch.index.query.MatchPhraseQueryBuilder; |
|
|
|
import org.elasticsearch.index.query.QueryBuilder; |
|
|
|
import org.elasticsearch.index.query.QueryBuilder; |
|
|
|
import org.elasticsearch.index.query.QueryBuilders; |
|
|
|
import org.elasticsearch.index.query.QueryBuilders; |
|
|
|
import org.elasticsearch.search.SearchHits; |
|
|
|
import org.elasticsearch.search.SearchHits; |
|
|
@ -138,11 +139,16 @@ public class FileSearchService { |
|
|
|
return PageVo.ofSearchHits(response.getHits(), param); |
|
|
|
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 { |
|
|
|
public PageVo<Object> searchImage(String dirId, String searchText, int pageNo, int pageSize) throws IOException { |
|
|
|
SearchRequest request = Requests.searchRequest("shandan"); |
|
|
|
SearchRequest request = Requests.searchRequest("shandan"); |
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); |
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); |
|
|
@ -159,8 +165,9 @@ public class FileSearchService { |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.hasText(searchText)) { |
|
|
|
if (StringUtils.hasText(searchText)) { |
|
|
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); |
|
|
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); |
|
|
|
boolQuery.should(QueryBuilders.matchPhraseQuery("fileName", searchText)); |
|
|
|
MatchPhraseQueryBuilder matchPhraseQuery = QueryBuilders.matchPhraseQuery("fileName", searchText); |
|
|
|
queryBuilder.must(boolQuery); |
|
|
|
boolQuery.should(); |
|
|
|
|
|
|
|
queryBuilder.must(matchPhraseQuery); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
searchSourceBuilder.query(queryBuilder); |
|
|
|
searchSourceBuilder.query(queryBuilder); |
|
|
@ -184,4 +191,10 @@ public class FileSearchService { |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
return PageVo.ofSearchHits(response.getHits(), page); |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|