|
|
|
@@ -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) |
|
|
|
|