summaryrefslogtreecommitdiffstats
path: root/modules/indexer/code/elasticsearch/elasticsearch.go
diff options
context:
space:
mode:
author6543 <m.huber@kithara.com>2024-03-09 02:39:27 +0100
committerGitHub <noreply@github.com>2024-03-09 01:39:27 +0000
commit7fdc0481538151d8a5ed3ec2a32639950f5d8ac6 (patch)
treece93a89a4fde28a2ae063d95f302eea9d4d003fe /modules/indexer/code/elasticsearch/elasticsearch.go
parentbaeb2511741aa70d24a48fd46db936b52be9d9dd (diff)
downloadgitea-7fdc0481538151d8a5ed3ec2a32639950f5d8ac6.tar.gz
gitea-7fdc0481538151d8a5ed3ec2a32639950f5d8ac6.zip
Patch in exact search for meilisearch (#29671)
meilisearch does not have an search option to contorl fuzzynes per query right now: - https://github.com/meilisearch/meilisearch/issues/1192 - https://github.com/orgs/meilisearch/discussions/377 - https://github.com/meilisearch/meilisearch/discussions/1096 so we have to create a workaround by post-filter the search result in gitea until this is addressed. For future works I added an option in backend only atm, to enable fuzzynes for issue indexer too. And also refactored the code so the fuzzy option is equal in logic to code indexer --- *Sponsored by Kithara Software GmbH*
Diffstat (limited to 'modules/indexer/code/elasticsearch/elasticsearch.go')
-rw-r--r--modules/indexer/code/elasticsearch/elasticsearch.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/indexer/code/elasticsearch/elasticsearch.go b/modules/indexer/code/elasticsearch/elasticsearch.go
index 0f70f13485..065b0b2061 100644
--- a/modules/indexer/code/elasticsearch/elasticsearch.go
+++ b/modules/indexer/code/elasticsearch/elasticsearch.go
@@ -281,10 +281,10 @@ func extractAggs(searchResult *elastic.SearchResult) []*internal.SearchResultLan
}
// Search searches for codes and language stats by given conditions.
-func (b *Indexer) Search(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int64, []*internal.SearchResult, []*internal.SearchResultLanguages, error) {
- searchType := esMultiMatchTypeBestFields
- if isMatch {
- searchType = esMultiMatchTypePhrasePrefix
+func (b *Indexer) Search(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isFuzzy bool) (int64, []*internal.SearchResult, []*internal.SearchResultLanguages, error) {
+ searchType := esMultiMatchTypePhrasePrefix
+ if isFuzzy {
+ searchType = esMultiMatchTypeBestFields
}
kwQuery := elastic.NewMultiMatchQuery(keyword, "content").Type(searchType)