Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug on elastic search #12811

Merged
merged 6 commits into from Sep 12, 2020
Merged

Fix bug on elastic search #12811

merged 6 commits into from Sep 12, 2020

Conversation

lunny
Copy link
Member

@lunny lunny commented Sep 11, 2020

When input two words or some Unicode texts on the search box, the default elastic search highlighting plugin will return content with high light html tags. i.e. <em>word1</em> <em>word2</em>.
But the previous codes will try to find <em>word1 word2</em> and return startIndex = endIndex = -1 which will resutl in a panic.

Should fix #12791

Since the new mapping option "term_vector": "with_positions_offsets" added, you have to delete your index previously.
You can try

curl -XDELETE http://localhost:9200/gitea_codes.v1

And restart gitea, the index will be rebuilt.

The new option will increse the space of the index but get faster on returning words positions.

@lunny lunny added type/bug skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Sep 11, 2020
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 11, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2020

Codecov Report

Merging #12811 into master will increase coverage by 0.01%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12811      +/-   ##
==========================================
+ Coverage   43.12%   43.14%   +0.01%     
==========================================
  Files         654      654              
  Lines       72194    72205      +11     
==========================================
+ Hits        31133    31152      +19     
+ Misses      36010    36008       -2     
+ Partials     5051     5045       -6     
Impacted Files Coverage Δ
modules/indexer/code/elastic_search.go 1.76% <16.66%> (+1.76%) ⬆️
modules/log/event.go 57.54% <0.00%> (-1.89%) ⬇️
services/pull/check.go 47.69% <0.00%> (-0.77%) ⬇️
services/pull/pull.go 42.03% <0.00%> (+0.46%) ⬆️
modules/git/repo.go 49.74% <0.00%> (+0.50%) ⬆️
models/gpg_key.go 55.40% <0.00%> (+0.58%) ⬆️
modules/git/utils.go 77.04% <0.00%> (+3.27%) ⬆️
modules/git/repo_language_stats.go 56.60% <0.00%> (+3.77%) ⬆️
modules/indexer/stats/queue.go 76.47% <0.00%> (+23.52%) ⬆️
modules/indexer/stats/db.go 69.56% <0.00%> (+26.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae528d8...3604196. Read the comment docs.

@lunny
Copy link
Member Author

lunny commented Sep 11, 2020

@zeripath done.

@lafriks lafriks added this to the 1.13.0 milestone Sep 11, 2020
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 11, 2020
@lunny
Copy link
Member Author

lunny commented Sep 12, 2020

@zeripath done.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 12, 2020
@zeripath
Copy link
Contributor

So need to figure out what happens with content

@lunny
Copy link
Member Author

lunny commented Sep 12, 2020

@zeripath Updated on the first comment of mine.

@lunny lunny merged commit 8ce10fb into go-gitea:master Sep 12, 2020
@lunny lunny deleted the lunny/fix_es_code branch September 12, 2020 12:31
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Code search failed with Elastic Search and Chinese characters
5 participants