{"id":17209721,"url":"https://github.com/ysc/jsearch","last_synced_at":"2025-04-13T22:31:43.758Z","repository":{"id":32170637,"uuid":"35743923","full_name":"ysc/jsearch","owner":"ysc","description":"jsearch：高性能的全文检索工具包","archived":false,"fork":false,"pushed_at":"2017-05-15T03:45:03.000Z","size":24227,"stargazers_count":93,"open_issues_count":0,"forks_count":43,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-27T12:52:38.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/ysc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-16T23:18:41.000Z","updated_at":"2025-01-09T14:15:52.000Z","dependencies_parsed_at":"2022-08-30T14:11:43.192Z","dependency_job_id":null,"html_url":"https://github.com/ysc/jsearch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysc%2Fjsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysc%2Fjsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysc%2Fjsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysc%2Fjsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ysc","download_url":"https://codeload.github.com/ysc/jsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248790627,"owners_count":21162059,"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-10-15T02:52:25.077Z","updated_at":"2025-04-13T22:31:38.974Z","avatar_url":"https://github.com/ysc.png","language":"Java","funding_links":[],"categories":["数据库"],"sub_categories":["Spring Cloud框架"],"readme":"### jsearch是一个高性能的全文检索工具包，基于倒排索引，基于java8，类似于lucene，但更轻量级。\n\n#### [捐赠致谢](https://github.com/ysc/QuestionAnsweringSystem/wiki/donation)\n\n#### 使用方法\n\n    1、依赖\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.apdplat\u003c/groupId\u003e\n            \u003cartifactId\u003ejsearch\u003c/artifactId\u003e\n            \u003cversion\u003e1.0\u003c/version\u003e\n        \u003c/dependency\u003e\n    2、索引\n        //存储索引的文件\n        String index = \"data/index\";\n        //存储以行为单位的原文的文件\n        String indexText = \"data/index_text\";\n        int indexLengthLimit = 1000;\n        //textPath可以为目录也可以为文件\n        String textPath = \"data/original/text\";\n        TextIndexer textIndexer = new TextIndexer(index, indexText, indexLengthLimit);\n        textIndexer.indexDir(textPath);\n    3、搜索\n        int pageSize = 100;\n        TextSearcher textSearcher = new TextSearcher(index, indexText);\n        textSearcher.setPageSize(pageSize);\n        textSearcher.setScore(new WordFrequencyScore());\n        Hits hits = textSearcher.search(\"hive function\", SearchMode.INTERSECTION);\n        System.out.println(\"搜索结果数：\"+hits.getHitCount());\n        AtomicInteger j = new AtomicInteger();\n        hits.getDocs().forEach(doc -\u003e System.out.println(\"Result\" + j.incrementAndGet() + \"、ID：\" + doc.getId() + \"，Score：\" + doc.getScore() + \"，Text：\" + doc.getText()));\n\n#### 索引文件结构\n\n    1、一个词的索引由=分割的三部分组成：\n        第一部分是词\n        第二部分是这个词在多少个文档中出现过（上限1000）\n        第三部分是倒排表\n    2、倒排表由多个倒排表项目组成，倒排表项目之间使用|分割\n    3、倒排表项目的组成又分为三部分，用_分割：\n        第一部分是文档ID\n        第二部分是词频\n        第三部分是词的位置\n    4、词的位置用:分割\n    \n    例如:\n    shingles=31=47466_1_2|1_1_6|1_1_1|2_1_5|67_1_1|903_1_3|17_1_5|1_3_4:6:11\n    表示词 shingles 的索引：\n    词：shingles\n    有 31 个文档包含 shingles 这个词\n    包含这个词的第一篇文档的ID是47466，\n    shingles 的词频是1，出现 shingles 的位置是2\n    文档内容为：\n    A better solution is to use shingles, which are compound tokens created \n    from multiple adjacent tokens.\n    对文档内容进行分词并移除停用词之后的结果为：\n    [solution, shingles, compound, tokens, created, multiple, adjacent, tokens]\n    \n    包含这个词的第二篇文档的ID是47466+1=47467，\n    shingles 的词频是1，出现 shingles 的位置是6\n    文档内容为：\n    Lucene has a sandbox module that simplifies adding shingles to your index, \n    described in section 8.3.2\n    对文档内容进行分词并移除停用词之后的结果为：\n    [lucene, sandbox, module, simplifies, adding, shingles, index, section]\n    \n    包含这个词的第八篇文档的ID是47466+1+1+2+67+903+17+1=48458，\n    shingles 的词频是3，出现 shingles 的位置分别是4、6、11\n    文档内容为：\n    For example the sentence “please divide this sentence into shingles” \n    might be tokenized into the shingles “please divide”, “divide this”, \n    “this sentence”, “sentence into” and “into shingles”\n    对文档内容进行分词并移除停用词之后的结果为：\n    [sentence, divide, sentence, shingles, tokenized, shingles, divide, divide, sentence, sentence, shingles]\n    \n    这里需要注意的是位置不是和原文一一对应的，而是和去除停用词后的位置一一对应的\n    分词使用word分词提供的针对纯英文文本的分词器\n    \n[停用词的定义](https://github.com/ysc/word/blob/master/src/main/resources/stopwords.txt)\n\n[word分词提供的针对纯英文文本的分词器](https://github.com/ysc/word/blob/master/src/main/java/org/apdplat/word/segmentation/impl/PureEnglish.java)\n\n[word分词](https://github.com/ysc/word)\n        \n[https://travis-ci.org/ysc/jsearch](https://travis-ci.org/ysc/jsearch)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysc%2Fjsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fysc%2Fjsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysc%2Fjsearch/lists"}