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

Code/repo search #2582

Merged
merged 1 commit into from
Oct 27, 2017
Merged

Code/repo search #2582

merged 1 commit into from
Oct 27, 2017

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Sep 23, 2017

Indexed search of repository contents (for default branch only). Implements #1102.

Details/features:

  • Adds a new bleve index for repository contents
  • Indexing supports unicode normalization and camelCase sensitivity
  • Excludes non-text files, and files larger than a configurable threshold (default 512 MB)
  • Integration tests

Current Screenshots:

code

top

bottom

Old Screenshots (for comparison):

old top

@codecov-io
Copy link

codecov-io commented Sep 23, 2017

Codecov Report

Merging #2582 into master will decrease coverage by 0.33%.
The diff coverage is 0.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2582      +/-   ##
==========================================
- Coverage    27.2%   26.86%   -0.34%     
==========================================
  Files          88       89       +1     
  Lines       17374    17596     +222     
==========================================
+ Hits         4726     4727       +1     
- Misses      11962    12183     +221     
  Partials      686      686
Impacted Files Coverage Δ
models/repo_editor.go 0% <0%> (ø) ⬆️
models/repo.go 13.03% <0%> (-0.03%) ⬇️
models/repo_indexer.go 0% <0%> (ø)
models/update.go 9.95% <0%> (-0.16%) ⬇️
models/models.go 28.07% <7.69%> (-1.1%) ⬇️

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 762f1d7...e04b069. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 23, 2017
@lunny lunny added this to the 1.x.x milestone Sep 23, 2017
@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Sep 23, 2017
@lunny
Copy link
Member

lunny commented Sep 23, 2017

Issue related changed should be a separate PR.

@@ -642,6 +642,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/:username/:reponame", func() {
m.Get("/stars", repo.Stars)
m.Get("/watchers", repo.Watchers)
m.Get("/search", repo.Search)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnitTypeCode required

Copy link
Member

@lafriks lafriks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also app.ini file needs to be updated with default values. And integration testing ini files


func addLastIndexSyncToRepository(x *xorm.Engine) error {
type Repository struct {
LastIndexSync string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From name it's not really understandable what is stored here. Time? Commit Sha?

models/models.go Outdated
@@ -150,7 +150,9 @@ func LoadConfigs() {

sec = setting.Cfg.Section("indexer")
setting.Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString("indexers/issues.bleve")
setting.Indexer.RepoPath = sec.Key("REPO_INDEXER_PATH").MustString("indexers/repos.bleve")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if path is relative and make it absolute if is.

@ethantkoenig
Copy link
Member Author

@lunny @lafriks I have addressed your comments

See also #2590.

@ethantkoenig
Copy link
Member Author

Rebased to resolve merge conflict

models/models.go Outdated
@@ -335,3 +340,14 @@ func DumpDatabase(filePath string, dbType string) error {
}
return x.DumpTablesToFile(tbs, filePath)
}

func absolutePath(path string) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about to move this to util package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

models/repo.go Outdated
ForkID int64 `xorm:"INDEX"`
BaseRepo *Repository `xorm:"-"`
Size int64 `xorm:"NOT NULL DEFAULT 0"`
IndexCommitSha string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a standalone table to store RepoID, BranchName, LastCommitSHA, so that we can support search for an extra branch.

@lunny
Copy link
Member

lunny commented Sep 25, 2017

And maybe put the search input box on Code tab right of the description of the repository with an internal search button in input box.

@lunny
Copy link
Member

lunny commented Sep 25, 2017

When I click the line number of search result page. it will show http://localhost:3000/lunny/builder/search?q=Cond#undefined on web browser.
I prefer to add a link on the highlight line to the view file but with the line number.

@ethantkoenig
Copy link
Member Author

Added line number links, hopefully I will be able to address the rest of your suggestions soon

@lunny
Copy link
Member

lunny commented Sep 28, 2017

@ethantkoenig I think only left one from me: Maybe a standalone table to store RepoID, BranchName, LastCommitSHA, so that we can support search for an extra branch.

@sapk
Copy link
Member

sapk commented Sep 28, 2017

@lunny searching in every branch could had too much work or maybe (in other PR) we should let the user select the branch with the option of all but by default only the default branch.

@lunny
Copy link
Member

lunny commented Sep 28, 2017

@ethantkoenig @sapk only support one branch is also OK. I only want the new struct of the table for flexible design.

@ethantkoenig ethantkoenig force-pushed the repo_search branch 2 times, most recently from a58f214 to df9bccb Compare September 29, 2017 05:00
@ethantkoenig
Copy link
Member Author

@lunny Moved indexer commit shas to a separate table. In the future, the table can be extended to support multiple branches.

@ethantkoenig
Copy link
Member Author

ethantkoenig commented Sep 30, 2017

CI is failing because latest migration (add repo_indexer_status table) is not happening. The CI databases are already at version 46 due to CI runs of #2621, so it thinks my migration has already been completed.

This seems like a problem that can/will occur regularly, we should try to fix a solution for it.

Edit: never mind, I just forgot to add the new table to tables in models/models.go

@lafriks
Copy link
Member

lafriks commented Sep 30, 2017

@ethantkoenig for each run I think new DB instance is created. Also I don't think migrations are run for integration tests

vdbt pushed a commit to vdbt/gitea that referenced this pull request Oct 27, 2017
Indexed search of repository contents (for default branch only)
@ethantkoenig
Copy link
Member Author

ethantkoenig commented Oct 27, 2017

@lafriks I don't think so (this code doesn't directly touch merging), but I'll take a closer look when I get the chance

@webjoel
Copy link
Contributor

webjoel commented Oct 27, 2017

@ethantkoenig Where is the option setting to enable/disable repo indexer? Only in app.ini?

@lafriks
Copy link
Member

lafriks commented Oct 27, 2017

@webjoel in app.ini file

[indexer]
REPO_INDEXER_ENABLED = false

@webjoel
Copy link
Contributor

webjoel commented Oct 27, 2017

@ethantkoenig @lafriks In try gitea demo it would be better to come true by default, or not?

@lafriks
Copy link
Member

lafriks commented Oct 27, 2017

@webjoel I'm not sure our demo server disk resources allow that as than we would need to create some kind of automatic cleanup there

@webjoel
Copy link
Contributor

webjoel commented Oct 27, 2017

Okay, I imagined something like that. Is that the way it is, disabled by default, the functionality was half hidden.

@lafriks
Copy link
Member

lafriks commented Oct 27, 2017

@webjoel For my test repositories that total in 121 MB index size was 735 MB

@webjoel
Copy link
Contributor

webjoel commented Oct 27, 2017

@lafriks In a production environment is have to be very careful. It's important, but the use of this feature should be well evaluated. can be done as you said, deleting the index every day midnight for example. Currently has how to know the space used in the demo with repositories?

@ethantkoenig ethantkoenig deleted the repo_search branch October 27, 2017 19:16
@lflare
Copy link
Contributor

lflare commented Oct 30, 2017

This is a bit later but I'm experiencing somewhat of a memory leak when initializing the indexer.

2017/10/30 07:15:55 [T] Custom path: /opt/gitea/custom
2017/10/30 07:15:55 [T] Log path: /opt/gitea/data/log
fatal error: out of memory

runtime stack:
runtime.throw(0xcae512, 0xd)
	/usr/local/go/src/runtime/panic.go:605 +0x70
runtime.(*mcache).refill(0x76f79000, 0xb, 0x0)
	/usr/local/go/src/runtime/mcache.go:125 +0xec
runtime.(*mcache).nextFree.func1()
	/usr/local/go/src/runtime/malloc.go:557 +0x24
runtime.systemstack(0x13d1a000)
	/usr/local/go/src/runtime/asm_arm.s:264 +0x80
runtime.mstart()
	/usr/local/go/src/runtime/proc.go:1125

goroutine 1 [running]:
runtime.systemstack_switch()
	/usr/local/go/src/runtime/asm_arm.s:209 +0x4 fp=0x14218b40 sp=0x14218b3c pc=0x673cc
runtime.(*mcache).nextFree(0x76f79000, 0xb, 0x7ee407e0, 0x7e30d514, 0x1f600)
	/usr/local/go/src/runtime/malloc.go:556 +0x8c fp=0x14218b6c sp=0x14218b40 pc=0x1f68c
runtime.mallocgc(0x40, 0xbb5998, 0x536301, 0x7ee40c60)
	/usr/local/go/src/runtime/malloc.go:711 +0x630 fp=0x14218bc8 sp=0x14218b6c pc=0x1fe8c
runtime.makeslice(0xbb5998, 0x35, 0x35, 0x7ee40c60, 0x11, 0x11)
	/usr/local/go/src/runtime/slice.go:54 +0x68 fp=0x14218bdc sp=0x14218bc8 pc=0x530c4
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*node).dereference(0x20ec1340)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/node.go:534 +0x88 fp=0x14218c34 sp=0x14218bdc pc=0x536258
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*node).dereference(0x20dd7e40)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/node.go:546 +0x230 fp=0x14218c8c sp=0x14218c34 pc=0x536400
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*node).dereference(0x1456a040)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/node.go:546 +0x230 fp=0x14218ce4 sp=0x14218c8c pc=0x536400
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*Bucket).dereference(0x5ded6060)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/bucket.go:695 +0x8c fp=0x14218d24 sp=0x14218ce4 pc=0x52cef8
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*Bucket).dereference(0x158ec00c)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/bucket.go:699 +0x5c fp=0x14218d64 sp=0x14218d24 pc=0x52cec8
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*DB).mmap(0x1417c000, 0x1000000, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/db.go:268 +0x2e4 fp=0x14218da4 sp=0x14218d64 pc=0x52f8d4
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*DB).allocate(0x1417c000, 0x1, 0x1456a0c0, 0x54a2b780, 0x9)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/db.go:849 +0x12c fp=0x14218dd0 sp=0x14218da4 pc=0x53175c
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*Tx).allocate(0x158ec000, 0x1, 0x1b, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/tx.go:456 +0x28 fp=0x14218dec sp=0x14218dd0 pc=0x53935c
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*node).spill(0x1456a440, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/node.go:368 +0x25c fp=0x14218e68 sp=0x14218dec pc=0x5350e8
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*node).spill(0x1456a0c0, 0x259c8ca0, 0x1392728)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/node.go:350 +0x90 fp=0x14218ee4 sp=0x14218e68 pc=0x534f1c
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*node).spill(0x1456a040, 0x5ded6080, 0x142190a0)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/node.go:350 +0x90 fp=0x14218f60 sp=0x14218ee4 pc=0x534f1c
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*Bucket).spill(0x5ded6060, 0x5ded6000, 0x14219210)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/bucket.go:570 +0x37c fp=0x142190d0 sp=0x14218f60 pc=0x52c3e8
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*Bucket).spill(0x158ec00c, 0xbe75d4c9, 0x8e0eb816)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/bucket.go:537 +0x2d8 fp=0x14219240 sp=0x142190d0 pc=0x52c344
code.gitea.io/gitea/vendor/github.com/boltdb/bolt.(*Tx).Commit(0x158ec000, 0x13d000f4, 0x1421930c)
	/go/src/code.gitea.io/gitea/vendor/github.com/boltdb/bolt/tx.go:163 +0xb8 fp=0x142192f8 sp=0x14219240 pc=0x5378ec
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/store/boltdb.(*Writer).ExecuteBatch.func1(0x142193d4, 0x158ec000)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/store/boltdb/writer.go:52 +0x3c fp=0x14219308 sp=0x142192f8 pc=0x53e0a4
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/store/boltdb.(*Writer).ExecuteBatch(0x1426bac8, 0x1393db8, 0x3863ed10, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/store/boltdb/writer.go:90 +0x3a4 fp=0x142193c4 sp=0x14219308 pc=0x53dd04
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/upsidedown.(*UpsideDownCouch).batchRows(0x1415e0c0, 0x1393200, 0x1426bac8, 0x39082000, 0x10, 0x10, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/upsidedown/upsidedown.go:292 +0x1090 fp=0x14219710 sp=0x142193c4 pc=0x51c1e0
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/upsidedown.(*UpsideDownCouch).Batch(0x1415e0c0, 0x141bb678, 0x14622e34, 0xb6bd48)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/upsidedown/upsidedown.go:939 +0xfa4 fp=0x14219a14 sp=0x14219710 pc=0x520ca4
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve.(*indexImpl).Batch(0x14622e10, 0x142698c0, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index_impl.go:304 +0x88 fp=0x14219a2c sp=0x14219a14 pc=0x57f8c0
code.gitea.io/gitea/modules/indexer.(*Batch).Flush(0x142698d0, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/modules/indexer/indexer.go:87 +0x30 fp=0x14219a4c sp=0x14219a2c pc=0x596c84
code.gitea.io/gitea/modules/indexer.(*Batch).flushIfFull(0x142698d0, 0x142698c0, 0x0)
	/go/src/code.gitea.io/gitea/modules/indexer/indexer.go:80 +0x50 fp=0x14219a5c sp=0x14219a4c pc=0x596c14
code.gitea.io/gitea/modules/indexer.(*Batch).Add(0x142698d0, 0x138e6d8, 0x141e60b0, 0x141e60b0, 0x14bd6000)
	/go/src/code.gitea.io/gitea/modules/indexer/indexer.go:75 +0x58 fp=0x14219a70 sp=0x14219a5c pc=0x596ba4
code.gitea.io/gitea/models.addUpdate(0x14230785, 0x25, 0x142f2380, 0x142698d0, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/models/repo_indexer.go:173 +0x21c fp=0x14219ac8 sp=0x14219a70 pc=0x7adc68
code.gitea.io/gitea/models.updateRepoIndexer(0x142f2380, 0x142ec3c0, 0xa)
	/go/src/code.gitea.io/gitea/models/repo_indexer.go:117 +0xac fp=0x14219af8 sp=0x14219ac8 pc=0x7ad698
code.gitea.io/gitea/models.populateRepoIndexer(0x0, 0x0)
	/go/src/code.gitea.io/gitea/models/repo_indexer.go:94 +0x74 fp=0x14219b74 sp=0x14219af8 pc=0x7ad498
code.gitea.io/gitea/modules/indexer.InitRepoIndexer(0xd050b4)
	/go/src/code.gitea.io/gitea/modules/indexer/repo.go:71 +0x124 fp=0x14219bb8 sp=0x14219b74 pc=0x5983cc
code.gitea.io/gitea/models.InitRepoIndexer()
	/go/src/code.gitea.io/gitea/models/repo_indexer.go:73 +0x2c fp=0x14219bcc sp=0x14219bb8 pc=0x7ad388
code.gitea.io/gitea/routers.GlobalInit()
	/go/src/code.gitea.io/gitea/routers/init.go:69 +0x30c fp=0x14219c28 sp=0x14219bcc pc=0x8f6b2c
code.gitea.io/gitea/cmd.runWeb(0x13d9c3c0, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/cmd/web.go:60 +0x74 fp=0x14219d04 sp=0x14219c28 pc=0xac2f58
code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(0xba1db0, 0xd05030, 0x13d9c3c0, 0x13f73100, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:471 +0x94 fp=0x14219d14 sp=0x14219d04 pc=0x7f345c
code.gitea.io/gitea/vendor/github.com/urfave/cli.Command.Run(0xc9ba4c, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcbfea6, 0x16, 0x0, ...)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:191 +0x74c fp=0x14219e70 sp=0x14219d14 pc=0x7f4258
code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(0x13d76680, 0x13d0c030, 0x2, 0x2, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:241 +0x404 fp=0x14219f58 sp=0x14219e70 pc=0x7f1dec
main.main()
	/go/src/code.gitea.io/gitea/main.go:48 +0x25c fp=0x14219fb8 sp=0x14219f58 pc=0xaca96c
runtime.main()
	/usr/local/go/src/runtime/proc.go:185 +0x1e0 fp=0x14219fe4 sp=0x14219fb8 pc=0x3d400
runtime.goexit()
	/usr/local/go/src/runtime/asm_arm.s:971 +0x4 fp=0x14219fe4 sp=0x14219fe4 pc=0x6942c

goroutine 52 [chan receive, 43 minutes]:
database/sql.(*DB).connectionOpener(0x13de1ec0)
	/usr/local/go/src/database/sql/sql.go:871 +0x40
created by database/sql.Open
	/usr/local/go/src/database/sql/sql.go:609 +0x1a0

goroutine 50 [chan receive, 43 minutes]:
code.gitea.io/gitea/modules/mailer.processMailQueue()
	/go/src/code.gitea.io/gitea/modules/mailer/mailer.go:244 +0x3c
created by code.gitea.io/gitea/modules/mailer.NewContext
	/go/src/code.gitea.io/gitea/modules/mailer/mailer.go:276 +0xc8

goroutine 9 [select, 4 minutes]:
code.gitea.io/gitea/modules/log.(*Logger).StartLogger(0x13d6cd20)
	/go/src/code.gitea.io/gitea/modules/log/log.go:261 +0xd8
created by code.gitea.io/gitea/modules/log.newLogger
	/go/src/code.gitea.io/gitea/modules/log/log.go:191 +0xc0

goroutine 10 [select, 43 minutes]:
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.AnalysisWorker(0x13d51a00, 0x13d51a40)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:75 +0xe4
created by code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.NewAnalysisQueue
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:67 +0xbc

goroutine 11 [select, 43 minutes]:
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.AnalysisWorker(0x13d51a00, 0x13d51a40)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:75 +0xe4
created by code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.NewAnalysisQueue
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:67 +0xbc

goroutine 12 [select, 42 minutes]:
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.AnalysisWorker(0x13d51a00, 0x13d51a40)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:75 +0xe4
created by code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.NewAnalysisQueue
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:67 +0xbc

goroutine 13 [select, 43 minutes]:
code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.AnalysisWorker(0x13d51a00, 0x13d51a40)
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:75 +0xe4
created by code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index.NewAnalysisQueue
	/go/src/code.gitea.io/gitea/vendor/github.com/blevesearch/bleve/index/analysis.go:67 +0xbc

goroutine 15 [chan receive, 43 minutes]:
code.gitea.io/gitea/modules/notification.(*notificationService).Run(0x1bfcdc4)
	/go/src/code.gitea.io/gitea/modules/notification/notification.go:37 +0x48
created by code.gitea.io/gitea/modules/notification.init.0
	/go/src/code.gitea.io/gitea/modules/notification/notification.go:31 +0x30

goroutine 16 [syscall, 43 minutes]:
os/signal.signal_recv(0x0)
	/usr/local/go/src/runtime/sigqueue.go:131 +0x134
os/signal.loop()
	/usr/local/go/src/os/signal/signal_unix.go:22 +0x14
created by os/signal.init.0
	/usr/local/go/src/os/signal/signal_unix.go:28 +0x30

goroutine 18 [select, 4 minutes]:
code.gitea.io/gitea/modules/log.(*Logger).StartLogger(0x141227e0)
	/go/src/code.gitea.io/gitea/modules/log/log.go:261 +0xd8
created by code.gitea.io/gitea/modules/log.newLogger
	/go/src/code.gitea.io/gitea/modules/log/log.go:191 +0xc0

goroutine 19 [select, 4 minutes]:
code.gitea.io/gitea/modules/log.(*Logger).StartLogger(0x141228a0)
	/go/src/code.gitea.io/gitea/modules/log/log.go:261 +0xd8
created by code.gitea.io/gitea/modules/log.newLogger
	/go/src/code.gitea.io/gitea/modules/log/log.go:191 +0xc0

goroutine 155 [select, 4 minutes]:
code.gitea.io/gitea/vendor/github.com/gogits/cron.(*Cron).run(0x140dea00)
	/go/src/code.gitea.io/gitea/vendor/github.com/gogits/cron/cron.go:178 +0x4f8
created by code.gitea.io/gitea/vendor/github.com/gogits/cron.(*Cron).Start
	/go/src/code.gitea.io/gitea/vendor/github.com/gogits/cron/cron.go:140 +0x44

goroutine 339 [chan receive, 43 minutes]:
code.gitea.io/gitea/models.processIssueIndexerUpdateQueue()
	/go/src/code.gitea.io/gitea/models/issue_indexer.go:73 +0x200
created by code.gitea.io/gitea/models.InitIssueIndexer
	/go/src/code.gitea.io/gitea/models/issue_indexer.go:23 +0x6c

@HenrikBengtsson
Copy link
Contributor

In case someone else comes here from the 1.3.0-rc1 release notes. I've been running docker run -d --name=gitea -p 10022:22 -p 10080:3000 -v /var/lib/gitea:/data gitea/gitea:latest for a while and wanted to try out gitea/gitea:1.3.0-rc1. Crossing my fingers that one can migrate easily from 1.2.* to 1.3.0, I simply just stopped the old and starter the new. Seems to work. However, to enable search, I had to add

[indexer]
REPO_INDEXER_ENABLED = true

to my /var/lib/gitea/gitea/conf/app.ini and then I restarted the container. Whola. The 'Search Repository' field now shows under the Code tab.

@lafriks
Copy link
Member

lafriks commented Nov 17, 2017

@HenrikBengtsson it was intentionally left disabled by default as code search index database takes a lot of disk space - about 6 times more than repository size. So use with caution.

@HenrikBengtsson
Copy link
Contributor

@lafriks, yes I think I understood that. I'm my case, since I was coming from an older version, I didn't even have a [indexer] section in my app.ini ... or is that what you mean by "disabled" - lack of an entry?

About large search DB: I'll use with care. Have you had any discussion on being able to enable/disable search per user/org or repository?

PS. I'm a first-timer with Gitea so I haven't been around for other x.y.z -> x.y+1.0 updates. Does Gitea make it easy to do such updates? For instance, will Gitea have to be "reinstalled" such that an up-to-date app.ini with new entries while preserving existing settings is recreated? (If this discussion is better suited elsewhere, please feel free to move it there)

@lafriks
Copy link
Member

lafriks commented Nov 17, 2017

@HenrikBengtsson such discussion would be better in discord chat but in short yes, update is just replacing binary and restarting gitea. No need to change app.ini, missing entries will just have default values. So it's not always disabled if entry is missing, just in this case. Per org/repo search option it's something we will need but noone is working on this currently

@lunny lunny mentioned this pull request Dec 4, 2017
6 tasks
@laoshaw
Copy link

laoshaw commented Dec 4, 2017

assume i have a linux kernel source tree and some other large git trees, indexing might be too heavy(for disk and cpu), can I designate certain git repos for indexing instead of indexing all of the git repos? it will be nice if I can choose what to index, or even better, when to index(e.g. indexing at mid-night via cron).

@lunny
Copy link
Member

lunny commented Dec 4, 2017

@laoshaw That's what I think next step to do.

  1. Indexing init process should be run background so that will not stop the web start. But when init some repository, this repo will not accept push.
  2. Every repository could check if it needs search.
    @ethantkoenig

@xak2000
Copy link

xak2000 commented Feb 2, 2018

One downside is that, the search doesn't show all found results in single file.

For example, if a file includes UriComponentsBuilder string multiple times, only first occurence (usually import at the top of source file) is shown in search results. But often it is not what you really want - you want to find usages of this imported class.

Can this be improved? Should I open another issue for that?

@techknowlogick
Copy link
Member

@xak2000 GitHub only shows the first couple of results, not all.

@xak2000
Copy link

xak2000 commented Feb 2, 2018

@techknowlogick Yes, you are right. I'm not sure how it determine how much, though.

For example this search shows "Showing the top five matches" for one of the files:
image

But on other files it shows two or three. Maybe it is percent of total matches in the file or something.

But anyway the one is not enought I think.

@thehowl
Copy link
Contributor

thehowl commented Feb 26, 2018

Please open a separate issue, though, otherwise if the problem is left here then we won't be able to track it properly :) (edit: yes, I realise I'm a bit late on this, sorry about that >_>)

@sleleko
Copy link

sleleko commented Apr 10, 2019

Hello! How much load disk subsytem on server, if I enable indexer and set path for store his files ?

@lunny
Copy link
Member

lunny commented Apr 11, 2019

The code index will spend 3x of the codes disk according to the usage experiences.

@sichkarmg
Copy link

How can I search for code across all repositories in an organization?
The search works only by the name of the repository or its description.
I know how to enable code searching in one repository, but how in all?
Performance is not critical to me.
Thanks!

@lunny
Copy link
Member

lunny commented Nov 16, 2020

This is codes search, but not repositories search. The only place you can use it is in explore. This is default disabled, you have to enabled it in app.ini.

@sichkarmg
Copy link

sichkarmg commented Nov 16, 2020

This is codes search, but not repositories search. The only place you can use it is in explore. This is default disabled, you have to enabled it in app.ini.

yes im enable
REPO_INDEXER_ENABLED = true

Thank you, sorry there is no organization filter. But it suits me
my.site/explore/code

@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. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.