doc.add(new Field("file",file.getName(),Field.Store.YES,Field.Index.NO));
//doc.add(Field.UnIndexed("file", file.getName()));
后者在lucene的后续版本中找不到了,可能是被抛弃的方法吧.现在用上面的方法代替.
org.apache.lucene.analysis包
org.apache.lucene.analysis.br包:Analyzer for Brazilian(巴西);
org.apache.lucene.analysis.cjk包:Analyzer for Chinese,Japanese,Korean(韩国);
org.apache.lucene.analysis.cn包:Analyzer for Chinese(中国);
org.apache.lucene.analysis.cz包:Analyzer for Czech(捷克);
org.apache.lucene.analysis.de包:Analyzer for German(德国);
org.apache.lucene.analysis.el包:Analyzer for Greek(希腊);
org.apache.lucene.analysis.fr包:Analyzer for French(法国);
org.apache.lucene.analysis.nl包:Analyzer for Dutch(荷兰);
org.apache.lucene.analysis.ru包:Analyzer for Russian(俄国);
org.apache.lucene.analysis.cn下有三个class:
ChineseAnalyzer:analyzer的子类
ChineseFilter
ChineseTokenizer
Field.Index.NO:不索引Field的值
Field.Index.NO_NORMS:索引Field的值without解析器(Analyzer),and disable the storing of norms
Field.Index.TOKENIZED:索引Field的值,使它能被查到
Field.Index.UN_TOKENIZED:索引Field的值without解析器(Analyzer),使它能被查到
Field.Store.COMPRESS:用压缩的格式在索引上存储最初的Field值
Field.Store.NO:不在索引上存储该Field的值
Field.Store.YES:为该Field值创建索引
java.lang.ClassCastException: org.apache.lucene.search.Hit
分享到:
相关推荐
此博文是对近期做lucene索引的总结, (lucene,solr,netty,hadoop),如蒙加入,不胜感激,大家共同探讨,本人争取每日一博,希望大家关注呦
org.apache.lucene.document.Field Directory类代表一个Lucene索引的位置。它是一个抽象类. 其中的两个实现: 第一个是 FSDirectory,它表示一个存储在文件系统中的索引的位置。 第二个是 RAMDirectory,它表示一...
lucene简介 1.1 什么是lucene Lucene是一个全文搜索框架,而不是应用产品。因此它并不像www.baidu.com 或者google Desktop那么拿来就能用,它只是提供了一种工具让你能实现这些产品。 2 lucene的工作方式 lucene...
LSql is a command-line tool written in Java that allows sql-like queries to run against a Lucene database. It can be run in interactive mode, or can automatically parse a list of commands from a file....
import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.queryParser.MultiFieldQueryParser; import org.apache....
Lucene一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎,部分文本分析引擎
lucene facet查询示例,区间查询多dim查询,key-field-value模型了解
doc.add(new Field("path", src.getCanonicalPath(), Field.Store.YES, Field.Index.NOT_ANALYZED)); StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(src)...
开源全文搜索工具包Lucene2.9.1的使用。 1. 搭建Lucene的开发环境:在classpath中添加lucene-core-2.9.1.jar包 2. 全文搜索的两个工作: 建立索引文件,搜索索引. 3. Lucene的索引文件逻辑结构 1) 索引(Index)由...
Lucene2.4入门总结lucene2.4 人门 field 多条件搜索
Lucene创建索引步骤: 1、创建Directory(索引位置) 2、创建IndexWrite(写入索引) 3、创建Document对象 4、为Document添加Field(相当于添加属性:类似于表与字段的关系) 5、通过IndexWriter添加文档到索引中
lucene lucene词典的构造原理 lucene模糊查询以及正则查询的原理 lucene删除索引的实现 lucene段merge的过程 lucene怎么实现Field lucene的分词过程
4、 Field域(重点) 5、 索引维护 a) 添加索引 b) 删除索引 c) 修改索引 6、 搜索(重点) a) 通过Query子类创建查询对象 b) 通过QueryParser创建查询对象 7、 相关度排序 8、 中文分词器(重点)
Lucene Query Tool (lqt) 是一个命令行工具用来执行 Lucene 查询并对结果进行格式化输出。 使用方法: $ ./lqt usage: LuceneQueryTool [options] --analyzer <arg> for query, (KeywordAnalyzer | ...
2. 域(Field)··· 17 3. 文档(document)··· 18 4. 段(segment)··· 19 5. IndexReader类与IndexWirter类··· 23 三、 数据流逻辑··· 24 四、 关于cLucene项目··· 25
完整代码,基于Lucene的分词,根据搜索引擎的目标和基本内容,将实现功能模块主要划分为创建中文分析器(创建索引)、读取索引文件查询记录、根据输入的内容进行分词、根据关键字进行全文检索、将结果按JSON格式输出...
Field:每个Document包含一个或多个不同命名的Field,每个Field对应一段数据,这些数据在搜索过程中可能会被查询或在索引中被检索 全文索引/搜索 Lucene索引代码示例: Directory dir = FSDirectory.getDirectory...
查看lucene索引文件的document和field
import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.search.Hits; import org.apache....