mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	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*
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user