
lucene
文章平均质量分 65
逗比123号
这人很懒,什么都没有写
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
lucene学习之创建索引
1.创建indexWriterDirectory d = FSDirectory.open(Paths.get("D:/lucene/index"));SmartChineseAnalyzer analyzer = new SmartChineseAnalyzer();IndexWriterConfig iwc = new IndexWriterConfig(analyzer);w原创 2016-04-20 14:23:28 · 363 阅读 · 0 评论 -
lucene学习之查询
Directory d = FSDirectory.open(Paths.get("D:/lucene/index"));IndexReader indexReader = DirectoryReader.open(d);System.out.println("maxdoc: "+indexReader.maxDoc());System.out.println("numdoc: "+i原创 2016-04-20 14:29:13 · 267 阅读 · 0 评论 -
lucene学习之分词信息
SmartChineseAnalyzer analyzer = new SmartChineseAnalyzer();TokenStream stream = analyzer.tokenStream("", new StringReader(str));//分词CharTermAttribute cta = stream.addAttribute(CharTermAttri原创 2016-04-20 14:31:58 · 271 阅读 · 0 评论 -
lucene学习之基础searcher排序
IndexSearcher is = new IndexSearcher(IndexReader indexreader);is.searcher(Query query,int n,sort);这里sort有Sort.INDEXORDER根据doc的id排序,Sort.RELEVANCE是默认排序,自定义排序就是新建一个SORT,new Sort(new SortField(Stri原创 2016-04-20 15:27:50 · 567 阅读 · 0 评论 -
lucene学习之简单的高亮显示
高亮会把你要搜索的字段用不同的样式显示出来。QueryScorer scorer=new QueryScorer(query);//这里传query对象Fragmenter fragmenter=new SimpleSpanFragmenter(scorer);SimpleHTMLFormatter simpleHTMLFormatter=new SimpleHTMLFormatter原创 2016-04-21 17:47:23 · 470 阅读 · 0 评论 -
lucene学习之自定义评分
想要根据城市来自定义评分,原来的输出:根据【你好.我是jack】 一共找到3文件编号:0 分数: 1.0 id: 1 city: 北京编号:1 分数: 1.0 id: 2 city: 南京编号:2 分数: 1.0 id: 3 city: 上海自己新建的query对象:public class MyFieldScoreQuery extends CustomScore原创 2016-04-21 09:56:52 · 421 阅读 · 0 评论 -
lucene学习之近实时搜索
近实时搜索是还没有提交,但是可以被搜索到。一般writer要等到一定量的修改后在提交,commit是很好性能的。public class IndexFenci {private static String[] ids = {"1","2","3"};private static String[] citys = {"北京","南京","上海"};private static S原创 2016-04-22 13:28:45 · 537 阅读 · 0 评论