Browse Source

增加用户搜索结果

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 3 years ago
parent
commit
083c645849
2 changed files with 6 additions and 2 deletions
  1. +2
    -2
      public/home/search.js
  2. +4
    -0
      routers/search.go

+ 2
- 2
public/home/search.js View File

@@ -155,14 +155,14 @@ function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){
html += " <span class=\"text grey\"><i class=\"ri-fire-line\"></i> " +recordMap["download_times"] + "</span> ";
html +=" </div>";
html += " <div class=\"ui header\">";
html += " <a class=\"name\" href=\"/" +recordMap["repoUrl"] +"datasets?type=0\">" + recordMap["repoUrl"] + "</a>";
html += " <a class=\"name\" href=\"/" +recordMap["repoUrl"] +"/datasets?type=0\">" + recordMap["repoUrl"] + "</a>";
html +=" <span class=\"middle\"><svg class=\"svg octicon-repo-clone\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-repo-clone\"></use></svg></span>";
html +=" </div>";
html += " <div class=\"description\">";
html += " <p class=\"has-emoji\"> " + recordMap["description"] + "</p>";
html += " <p class=\"has-emoji\"> " + recordMap["file_name"] + "</p>";
html +=" <p class=\"time\">";
html +=" <span class=\"am-ml-10\"></span> 最后更新于 <span class=\"time-since poping up\" title=\"\" data-content=\"\" data-variation=\"inverted tiny\">" + getTime(recordMap["updated_unix"],currentTime) +"</span>";
html +=" <span class=\"am-ml-10\"></span> 最后更新于 <span class=\"time-since poping up\" title=\"\" data-content=\"\" data-variation=\"inverted tiny\">" + getTime(recordMap["created_unix"],currentTime) +"</span>";
html +=" </p>";
html +=" </div>";
html +=" </div>";


+ 4
- 0
routers/search.go View File

@@ -394,6 +394,8 @@ func searchDataSet(ctx *context.Context, TableName string, Key string, Page int,
boolQ.Should(nameQuery, descQuery, categoryQuery, fileNameQuery)
res, err := client.Search(TableName).Query(boolQ).Sort(SortBy, ascending).From((Page - 1) * PageSize).Size(PageSize).Highlight(queryHighlight("title", "description", "file_name", "category")).Do(ctx.Req.Context())
if err == nil {
searchJson, _ := json.Marshal(res)
log.Info("searchJson=" + string(searchJson))
result := makeDatasetResult(res, Key, OnlyReturnNum)
ctx.JSON(200, result)
} else {
@@ -404,6 +406,8 @@ func searchDataSet(ctx *context.Context, TableName string, Key string, Page int,
//搜索的属性要指定{"timestamp":{"unmapped_type":"date"}}
res, err := client.Search(TableName).Sort(SortBy, ascending).From((Page - 1) * PageSize).Size(PageSize).Do(ctx.Req.Context())
if err == nil {
searchJson, _ := json.Marshal(res)
log.Info("searchJson=" + string(searchJson))
result := makeDatasetResult(res, "", OnlyReturnNum)
ctx.JSON(200, result)
} else {


Loading…
Cancel
Save