Lucene 初体验

来源:互联网 发布:php qq发邮件源代码 编辑:程序博客网 时间:2024/06/05 02:55

Lucene 版本 6.6.0,对 JDK 的要求 1.8 及以上。

[xiaochu.yh~/code/raywill] $javac -versionjavac 1.8.0_121

编译:

[xiaochu.yh~/code/raywill] $javac -classpath ./lucene/core/lucene-core-6.6.0.jar:./lucene/analysis/common/lucene-analyzers-common-6.6.0.jar:./lucene/queryparser/lucene-queryparser-6.6.0.jar:. IndexFiles.java[xiaochu.yh~/code/raywill] $javac -classpath ./lucene/core/lucene-core-6.6.0.jar:./lucene/analysis/common/lucene-analyzers-common-6.6.0.jar:./lucene/queryparser/lucene-queryparser-6.6.0.jar:. SearchFiles.java

建立索引命令:

[xiaochu.yh~/code/raywill] $cat index.sh java -classpath ./lucene/core/lucene-core-6.6.0.jar:./lucene/analysis/common/lucene-analyzers-common-6.6.0.jar:./lucene/queryparser/lucene-queryparser-6.6.0.jar:. IndexFiles -index luceneIndexData -docs  ~/kafaka.wiki/

生成索引后最终目录结构如下:

[xiaochu.yh~/code/raywill] $tree . -L 2.├── IndexFiles$1.class├── IndexFiles.class├── SearchFiles.class├── IndexFiles.java├── SearchFiles.java├── index.sh├── search.sh├── lucene│   ├── analysis│   ├── backward-codecs│   ├── benchmark│   ├── CHANGES.txt│   ├── classification│   ├── codecs│   ├── core│   ├── demo│   ├── docs│   ├── expressions│   ├── facet│   ├── grouping│   ├── highlighter│   ├── join│   ├── JRE_VERSION_MIGRATION.txt│   ├── licenses│   ├── LICENSE.txt│   ├── memory│   ├── MIGRATE.txt│   ├── misc│   ├── NOTICE.txt│   ├── queries│   ├── queryparser│   ├── README.txt│   ├── replicator│   ├── sandbox│   ├── spatial│   ├── spatial3d│   ├── spatial-extras│   ├── suggest│   ├── SYSTEM_REQUIREMENTS.txt│   └── test-framework├── luceneIndexData│   ├── _0.cfe│   ├── _0.cfs│   ├── _0.si│   ├── _7.cfe│   ├── _7.cfs│   ├── _7.si│   ├── _9.cfe│   ├── _9.cfs│   ├── _9.si│   ├── _e.dii│   ├── _e.dim│   ├── _e.fdt│   ├── _e.fdx│   ├── _e.fnm│   ├── _e_Lucene50_0.doc│   ├── _e_Lucene50_0.pos│   ├── _e_Lucene50_0.tim│   ├── _e_Lucene50_0.tip│   ├── _e.nvd│   ├── _e.nvm│   ├── _e.si│   ├── _o.dii│   ├── _o.dim│   ├── _o.fdt│   ├── _o.fdx│   ├── _o.fnm│   ├── _o_Lucene50_0.doc│   ├── _o_Lucene50_0.pos│   ├── _o_Lucene50_0.tim│   ├── _o_Lucene50_0.tip│   ├── _o.nvd│   ├── _o.nvm│   ├── _o.si│   ├── _p.cfe│   ├── _p.cfs│   ├── _p.si│   ├── segments_1│   └── write.lock

搜索脚本

[xiaochu.yh~/code/raywill] $cat search.sh java -classpath ./lucene/core/lucene-core-6.6.0.jar:./lucene/analysis/common/lucene-analyzers-common-6.6.0.jar:./lucene/queryparser/lucene-queryparser-6.6.0.jar:. SearchFiles -index luceneIndexData/

搜索结果:

[xiaochu.yh~/code/raywill] $sh search.sh Enter query: "版本发布"Searching for: "版 本 发 布"38 total matching documents1. /home/xiaochu.yh/Kafaka.wiki/lark/ka/oldwiki/版本变更.md2. /home/xiaochu.yh/Kafaka.wiki/oldwiki/版本变更.md3. /home/xiaochu.yh/Kafaka.wiki/index.md4. /home/xiaochu.yh/Kafaka.wiki/release_notes/Kafaka发布说明.md5. /home/xiaochu.yh/Kafaka.wiki/lark/ka/release/Kafaka正式版本-发布说明.mdPress (n)ext page, (q)uit or enter number to jump to a page.n6. /home/xiaochu.yh/Kafaka.wiki/lark/ka/oldwiki/开发测试流程规范.md7. /home/xiaochu.yh/Kafaka.wiki/oldwiki/开发测试流程规范.md8. /home/xiaochu.yh/Kafaka.wiki/lark/ka/upgrade/升级步骤.md9. /home/xiaochu.yh/Kafaka.wiki/qa/other/测试环境变更记录.md10. /home/xiaochu.yh/Kafaka.wiki/lark/ka/oldwiki/测试环境变更记录.mdPress (p)revious page, (n)ext page, (q)uit or enter number to jump to a page.

用来搜本地文档,不要太方便太迅速!


参考文档:

  • 6.6 Docs https://lucene.apache.org/core/6_6_0/index.html
  • 6.6 Demo https://lucene.apache.org/core/6_6_0/demo/index.html
原创粉丝点击