4 Commits

2 changed files with 9 additions and 7 deletions
Split View
  1. +1
    -1
      public/home/search.js
  2. +8
    -6
      routers/search.go

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

@@ -671,7 +671,7 @@ function displayModelResult(page, jsonResult, onlyReturnNum, keyword) {
<div class="ui right metas" style="color:#767676">${engineMap[recordMap['engine']] || 'Other'}</div>
<div class="ui header">
<a class="name" href="/explore/models/${recordMap["owerName"]}/${recordMap["real_name"]}" target="_blank">
${recordMap["name"]}
${recordMap["title"]}
</a>
</div>
<div class="description">


+ 8
- 6
routers/search.go View File

@@ -311,11 +311,10 @@ func searchRepo(ctx *context.Context, TableName string, Key string, Page int, Pa
if Key != "" {
boolQ := elastic.NewBoolQuery()
nameQuery := elastic.NewMatchQuery("alias", Key).Boost(1024).QueryName("f_first")
descriptionQuery := elastic.NewMatchQuery("description", Key).Boost(1.5).QueryName("f_second")
topicsQuery := elastic.NewMatchQuery("topics", Key).Boost(1).QueryName("f_third")
boolQ.Should(nameQuery, descriptionQuery, topicsQuery)
topicsQuery := elastic.NewMatchQuery("topics", Key).Boost(1).QueryName("f_second")
boolQ.Should(nameQuery, topicsQuery)

res, err := client.Search(TableName).Query(boolQ).SortBy(getSort(SortBy, ascending, "num_stars", false)...).From(from).Size(Size).Highlight(queryHighlight("alias", "description", "topics")).Do(ctx.Req.Context())
res, err := client.Search(TableName).Query(boolQ).SortBy(getSort(SortBy, ascending, "num_stars", false)...).From(from).Size(Size).Highlight(queryHighlight("alias", "topics")).Do(ctx.Req.Context())
if err == nil {
//searchJson, _ := json.Marshal(res)
//log.Info("searchJson=" + string(searchJson))
@@ -1304,10 +1303,10 @@ func searchModel(ctx *context.Context, TableName string, Key string, Page int, P
if Key != "" {
fileNameQuery := elastic.NewMatchQuery("file_name", Key).Boost(3).QueryName("f_first")
nameQuery := elastic.NewMatchQuery("name", Key).Boost(2).QueryName("f_second")
descQuery := elastic.NewMatchQuery("description", Key).Boost(1.5).QueryName("f_three")
descQuery := elastic.NewMatchQuery("alias", Key).Boost(1.5).QueryName("f_three")
labelQuery := elastic.NewMatchQuery("label", Key).Boost(1).QueryName("f_fourth")
boolQ.Should(fileNameQuery, nameQuery, descQuery, labelQuery)
res, err := client.Search(TableName).Query(boolQ).SortBy(getSort(SortBy, ascending, "updated_unix.keyword", false)...).From(from).Size(Size).Highlight(queryHighlight("file_name", "name", "description", "label")).Do(ctx.Req.Context())
res, err := client.Search(TableName).Query(boolQ).SortBy(getSort(SortBy, ascending, "updated_unix.keyword", false)...).From(from).Size(Size).Highlight(queryHighlight("file_name", "name", "alias", "label")).Do(ctx.Req.Context())
if err == nil {
//searchJson, _ := json.Marshal(res)
//log.Info("searchJson=" + string(searchJson))
@@ -1371,6 +1370,9 @@ func makePrivateModel(privateModels []*models.AiModelManage, res *SearchRes, Key
record["file_name"] = truncLongText(makeHighLight(Key, file_name), true)
record["name"] = makeHighLight(Key, model.Name)
record["title"] = makeHighLight(Key, model.Alias)
if record["title"] == "" {
record["title"] = record["name"]
}
record["real_name"] = model.Name
record["is_private"] = model.IsPrivate
record["description"] = truncLongText(makeHighLight(Key, model.Description), true)


Loading…
Cancel
Save
Baidu
map