Skip to content

Commit daa6451

Browse files
committed
Change the code search to sort results by relevance
Signed-off-by: Bruno Sofiato <[email protected]>
1 parent 3269b04 commit daa6451

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

modules/indexer/code/bleve/bleve.go

+2
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
284284
searchRequest.AddFacet("languages", bleve.NewFacetRequest("Language", 10))
285285
}
286286

287+
searchRequest.SortBy([]string{"-_score", "RepoID"})
288+
287289
result, err := b.inner.Indexer.SearchInContext(ctx, searchRequest)
288290
if err != nil {
289291
return 0, nil, nil, err

modules/indexer/code/elasticsearch/elasticsearch.go

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
318318
NumOfFragments(0). // return all highting content on fragments
319319
HighlighterType("fvh"),
320320
).
321+
Sort("_score", false).
321322
Sort("repo_id", true).
322323
From(start).Size(pageSize).
323324
Do(ctx)
@@ -349,6 +350,7 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
349350
NumOfFragments(0). // return all highting content on fragments
350351
HighlighterType("fvh"),
351352
).
353+
Sort("_score", false).
352354
Sort("repo_id", true).
353355
From(start).Size(pageSize).
354356
Do(ctx)

0 commit comments

Comments
 (0)