feat: 完善本地MCP与扩展市场能力
This commit is contained in:
@@ -53,6 +53,12 @@ public class ElasticsearchServiceImpl implements SearchService, ISearchRpcServic
|
||||
@Value("${search.elasticsearch.password:}")
|
||||
private String password;
|
||||
|
||||
@Value("${search.elasticsearch.text_analyzer:standard}")
|
||||
private String textAnalyzer;
|
||||
|
||||
@Value("${search.elasticsearch.search_analyzer:standard}")
|
||||
private String searchAnalyzer;
|
||||
|
||||
private ElasticsearchClient client;
|
||||
|
||||
@PostConstruct
|
||||
@@ -75,6 +81,14 @@ public class ElasticsearchServiceImpl implements SearchService, ISearchRpcServic
|
||||
client.shutdown();
|
||||
}
|
||||
|
||||
private String getTextAnalyzer() {
|
||||
return StringUtils.defaultIfBlank(textAnalyzer, "standard");
|
||||
}
|
||||
|
||||
private String getSearchAnalyzer() {
|
||||
return StringUtils.defaultIfBlank(searchAnalyzer, getTextAnalyzer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bulkIndex(List<SearchDocument> list) {
|
||||
Assert.noNullElements(list, "list cannot be left blank.");
|
||||
@@ -146,8 +160,8 @@ public class ElasticsearchServiceImpl implements SearchService, ISearchRpcServic
|
||||
if (keyword.get()) {
|
||||
builder.properties(name.get(), property -> property.keyword(kw -> kw.index(index.get()).store(store.get())));
|
||||
} else {
|
||||
builder.properties(name.get(), property -> property.text(text -> text.analyzer("ik_max_word")
|
||||
.searchAnalyzer("ik_smart").store(store.get()).index(index.get())
|
||||
builder.properties(name.get(), property -> property.text(text -> text.analyzer(getTextAnalyzer())
|
||||
.searchAnalyzer(getSearchAnalyzer()).store(store.get()).index(index.get())
|
||||
));
|
||||
}
|
||||
} else if (declaredField.getType() == Integer.class) {
|
||||
@@ -163,8 +177,8 @@ public class ElasticsearchServiceImpl implements SearchService, ISearchRpcServic
|
||||
} else if (declaredField.getType() == Date.class) {
|
||||
builder.properties(name.get(), property -> property.date(date -> date.index(index.get()).store(store.get())));
|
||||
} else {
|
||||
builder.properties(name.get(), property -> property.text(text -> text.analyzer("ik_max_word")
|
||||
.searchAnalyzer("ik_smart").store(store.get()).index(index.get())
|
||||
builder.properties(name.get(), property -> property.text(text -> text.analyzer(getTextAnalyzer())
|
||||
.searchAnalyzer(getSearchAnalyzer()).store(store.get()).index(index.get())
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xspaceagi.log.sdk.request.DocumentSearchRequest;
|
||||
import com.xspaceagi.log.sdk.service.ISearchRpcService;
|
||||
import com.xspaceagi.log.sdk.vo.LogDocument;
|
||||
import com.xspaceagi.log.sdk.vo.SearchResult;
|
||||
import com.xspaceagi.log.web.controller.dto.LogQueryDto;
|
||||
import com.xspaceagi.system.spec.common.RequestContext;
|
||||
import com.xspaceagi.system.spec.common.UserContext;
|
||||
@@ -19,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -125,13 +127,15 @@ public abstract class BaseController {
|
||||
createTimeRange.put("express", "range");
|
||||
filterFieldsAndValues.add(Map.of("createTime", createTimeRange));
|
||||
}
|
||||
builder.sortFieldsAndValues(Map.of("createTime", "Desc"));
|
||||
var result = iSearchRpcService.search(builder.build());
|
||||
|
||||
try {
|
||||
builder.sortFieldsAndValues(Map.of("createTime", "Desc"));
|
||||
var result = iSearchRpcService.search(builder.build());
|
||||
IPage<LogDocument> page = new Page<>(pageQueryVo.getCurrent().intValue(), pageQueryVo.getPageSize().intValue());
|
||||
page.setTotal(result.getTotal());
|
||||
page.setRecords(result.getItems().stream().map(item -> {
|
||||
page.setTotal(result == null || result.getTotal() == null ? 0 : result.getTotal());
|
||||
List<SearchResult.SearchResultItem> items = result == null || result.getItems() == null
|
||||
? Collections.emptyList()
|
||||
: result.getItems();
|
||||
page.setRecords(items.stream().map(item -> {
|
||||
LogDocument document = (LogDocument) item.getDocument();
|
||||
document.setProcessData(null);
|
||||
return document;
|
||||
|
||||
Reference in New Issue
Block a user