{"id":13522403,"url":"https://github.com/huichen/kunlun","last_synced_at":"2025-10-29T23:44:11.681Z","repository":{"id":45991083,"uuid":"430297038","full_name":"huichen/kunlun","owner":"huichen","description":"昆仑：超快的代码搜索引擎","archived":false,"fork":false,"pushed_at":"2021-11-30T07:42:58.000Z","size":8825,"stargazers_count":55,"open_issues_count":0,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-02T06:33:04.473Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huichen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-21T07:04:56.000Z","updated_at":"2024-11-01T09:37:37.000Z","dependencies_parsed_at":"2022-09-26T20:21:12.625Z","dependency_job_id":null,"html_url":"https://github.com/huichen/kunlun","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fkunlun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fkunlun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fkunlun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huichen%2Fkunlun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huichen","download_url":"https://codeload.github.com/huichen/kunlun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224760051,"owners_count":17365288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:00:46.788Z","updated_at":"2025-10-29T23:44:11.600Z","avatar_url":"https://github.com/huichen.png","language":"Go","funding_links":[],"categories":["CodeSearch","Go"],"sub_categories":[],"readme":"昆仑代码搜索引擎\n======\n\n* 支持亿行代码、多仓库、复杂表达式高速检索和实时查询\n* 超快的建索引速度：基于 [Unicode 三元组（trigram）的内存索引](/doc/index.md)，每分钟可索引超过 1000 万行代码\n* 超快的搜索速度：多数 query 百毫秒内返回，[优化了正则表达式查询](/doc/regexp.md)，和竞品相比有 [10 倍速度提升](/doc/benchmark.md)\n* 支持丰富的[搜索语言](/doc/query.md)，可以基于正则表达式、与或非逻辑运算、文件名、仓库名等搜索\n* 支持上百种编程语言的[检测和查询](/doc/language.md)\n* 支持丰富的[索引文件过滤选项](/doc/index_filter.md)\n* 支持基于 ctags 的[符号（变量、函数、类名等）查询](/doc/ctags.md)\n* 支持可扩展的[访问权限控制](/doc/acl.md)\n* 提供了 [KWS](/cmd/kws) 基于网页的搜索服务\n* 提供了 [KLS](/cmd/kls) 命令行下的代码搜索瑞士军刀程序\n* 采用对商业应用友好的 [Apache License v2](/LICENSE) 发布\n\n# 安装/更新\n\n```\ngo get -u -v github.com/huichen/kunlun\n```\n\n# 使用\n\n先看一个例子（来自[cmd/examples/simplest_example.go](/cmd/examples/simplest_example.go)）\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\n\t\"github.com/huichen/kunlun/pkg/engine\"\n\t\"github.com/huichen/kunlun/pkg/types\"\n)\n\nvar (\n\tdir   = flag.String(\"d\", \"/usr/local/include\", \"索引这个文件夹下的所有文件\")\n\tquery = flag.String(\"q\", \"gcc\", \"搜索表达式\")\n)\n\nfunc main() {\n\tflag.Parse()\n\n\t// 创建引擎\n\tkgn, _ := engine.NewKunlunEngine(nil) // 使用默认选项\n\n\t// 构建索引\n\tkgn.IndexDir(*dir)\n\tkgn.Finish() // 开始搜索前必须先调用该函数\n\n\t// 检索\n\trequest := types.SearchRequest{\n\t\tQuery:             *query,\n\t\tReturnLineContent: true,\n\t\tNumContextLines:   2}\n\tresp, _ := kgn.Search(request)\n\n\t// 打印输出\n\tkgn.PrettyPrintSearchResponse(resp, true, true)\n}\n```\n\n引擎提供了一系列[文件遍历选项](/pkg/types/walker_options.go)、[索引选项](/pkg/types/indexer_options.go)和[搜索选项](/pkg/types/searcher_options.go)，可以在引擎启动时通过[参数传入](/pkg/types/engine_options.go)。\n\n如果你想阅读昆仑的代码，可以先看看[这篇文档](/doc/codebase.md)。\n\n# 其它\n\n* [为什么要有昆仑](/doc/why.md)\n* [联系方式](/doc/feedback.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuichen%2Fkunlun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuichen%2Fkunlun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuichen%2Fkunlun/lists"}