Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接口切换 #26

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,31 @@ public SysResult searchDocByKeyword(@RequestBody @Validated SearchCondition cond
ParameterUtil.vaildListMap(condition.getLimit());
ParameterUtil.vaildListMap(condition.getFilter());
try {
Map<String, Object> result = searchService.searchByCondition(condition);
Map<String, Object> result = searchService.searchByConditionEs(condition);
if (result == null) {
return SysResult.fail("内容不存在", null);
}
return SysResult.ok("查询成功", result);
} catch (ControllerException e) {
log.error("searchByCondition error is: " + e.getMessage());
}
return SysResult.fail("查询失败", null);
}

/**
* 查询文档,首页大搜索-多路召回接口
*
* @param condition 封装查询条件
* @return 搜索结果
*/
@LogAction(type = "Global multi-search", OperationResource = "Documents")
@PostMapping("docsng")
@LimitRequest()
public SysResult multisearchDocByKeyword(@RequestBody @Validated SearchCondition condition) {
ParameterUtil.vaildListMap(condition.getLimit());
ParameterUtil.vaildListMap(condition.getFilter());
try {
Map<String, Object> result = searchService.searchByConditionMulti(condition);
if (result == null) {
return SysResult.fail("内容不存在", null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public interface SearchService {

Map<String, Object> getSuggestion(String keyword, String lang) throws ServiceException;

Map<String, Object> searchByCondition(SearchCondition condition) throws ServiceException;
Map<String, Object> searchByConditionMulti(SearchCondition condition) throws ServiceException;

Map<String, Object> searchByConditionEs(SearchCondition condition) throws ServiceException;

Map<String, Object> getCount(SearchCondition condition) throws ServiceException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,37 @@ public Map<String, Object> getSuggestion(String keyword, String lang) throws Ser

}


/**
* main page doc search
*
* @param condition the user query
* @return the search results
*/
@Override
public Map<String, Object> searchByCondition(SearchCondition condition) throws ServiceImplException {
public Map<String, Object> searchByConditionEs(SearchCondition condition) throws ServiceImplException {
//create es search strategy
EsSearchStrategy esRecall = new EsSearchStrategy(restHighLevelClient,mySystem.index,trie,esfunctionScoreConfig,fuProperties);
MultiSearchContext multirecall = new MultiSearchContext();
//set es search into search contex
multirecall.setSearchStrategy(esRecall);
//do recall and fetch the result
DataComposite multiRecallRes = multirecall.executeMultiSearch(condition);
if ("desc".equals(condition.getSort())) {
return multiRecallRes.getChild(0).getResList();
}
multiRecallRes.setFuProperties(fuProperties);
return multiRecallRes.mergeResult();
}

/**
* multi doc search
*
* @param condition the user query
* @return the search results
*/
@Override
public Map<String, Object> searchByConditionMulti(SearchCondition condition) throws ServiceImplException {
//create es search strategy
EsSearchStrategy esRecall = new EsSearchStrategy(restHighLevelClient,mySystem.index,trie,esfunctionScoreConfig,fuProperties);
GSearchStrategy gRecall = new GSearchStrategy(gProperties, httpConnectFactory);
Expand All @@ -243,7 +266,6 @@ public Map<String, Object> searchByCondition(SearchCondition condition) throws S
multiRecallRes.setFuProperties(fuProperties);
// multiRecallRes.filter("policy") filtering data here
return multiRecallRes.mergeResult();
//return multiRecallRes.getChild(1).getResList();
}

public SearchRequest BuildSearchRequest(SearchCondition condition, String index) {
Expand Down
Loading