/**
* 操作索引库是用来(增删改)索引
*
* @throws Exception
*/
@Test
public void createIndex() throws Exception
{
long star = System.currentTimeMillis();
IndexWriter indexWriter = null;
RAMDirectory ramDir = null;
FSDirectory dirs = FSDirectory.getDirectory(indexPath);
IndexWriter indexWriters = new IndexWriter(dirs, analyzer, MaxFieldLength.LIMITED);
for (int i = 0; i < 10000; i++)
{
File file = new File(indexPath);
FSDirectory dir = FSDirectory.getDirectory(file);
Document doc = File2DocumentUtils.file2Document(filePath);
ramDir = new RAMDirectory();
indexWriter = new IndexWriter(ramDir, analyzer, MaxFieldLength.LIMITED);
indexWriter.addDocument(doc);
indexWriter.close();
indexWriters.addIndexesNoOptimize(new Directory[] {ramDir});
}
indexWriters.close();
long end = System.currentTimeMillis();
System.out.println("消耗时间: " + (double) ((end - star) / 1000));
}
@Test
public void createIndex1() throws Exception
{
long star = System.currentTimeMillis();
for (int i = 0; i < 1000; i++)
{
File file = new File(indexPath);
FSDirectory dir = FSDirectory.getDirectory(file);
Document doc = File2DocumentUtils.file2Document(filePath);
IndexWriter indexWriter = new IndexWriter(dir, analyzer, MaxFieldLength.LIMITED);
indexWriter.addDocument(doc);
indexWriter.close();
}
long end = System.currentTimeMillis();
System.out.println("消耗时间: " + (double) ((end - star) / 1000));
}
分享到:
相关推荐
lucene并行索引
一步一步跟我学习lucene是对近期做lucene索引的总结,
lucene lucene构建索引,从HelloWorld到项目具体使用 ====================项目一:=================================== qianjun.lucene.first ...1,优化及其索引库内存加载 (好像依赖上面后两个包下的类) qianju
介绍了Lucene的基础知识,包括Lucene的历史和发展情况、使用Lucene创建索引和执行搜索的基本方法以及中文分词的应用,最后做了两个应用项目。第2部分:数据解析。介绍解析不同格式数据(如Word、PDF等)的方法,包括...
NULL 博文链接:https://mozhenghua.iteye.com/blog/2404089
其次,利用内存索引和多线程并行处理技术提高Lucene创建倒排索引效率,并依据地名类别和显示优先级属性优化了检索结果相关度排序策略。最后,开发了一套具有快速搜索和地图定位展示的Web地名检索系统,使用500万条...
* 创建索引 * @throws Exception */ public static int createIndex(List<?> list) throws Exception{ /**这里放索引文件的位置**/ File indexDir = new File(LucenePath); Analyzer luceneAnalyzer = ...
2.3 创建文档并且添加索引 4 2.4 查询索引的基本信息 5 2.5 删除和更新索引 5 (1) 使用writer删除 5 (2) 使用reader删除 5 (3) 恢复删除 5 (4) 彻底删除 6 (5) 更新索引 6 (6) 手动优化 6 2.6 索引文件作用 7 第三章...
//src要创建索引的文件,destDir索引存放的目录 public static void createIndex(File src, File destDir){ Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT); //创建一个语法分析器 ...
5. 创建索引 1) IndexWriter:索引写出器 a) 构造方法: IndexWriter(Directory d, Analyzer a, IndexWriter.MaxFieldLength mfl) 如果索引不存在,就会被创建。如果索引存在,就追加. IndexWriter(Directory ...
IndexSearcher:用于搜索IndexWriter创建的索引 Term:用于搜索的一个基本单元包括了一对字符串元素,与Field相对应 Query :抽象的查询类 TermQuery:最基本的查询类型,用来匹配特定Field中包含特定值的文档 Hits...
简单说明接口在...使用队列对索引创建优化,当前创建索引规则为:每次批量取出连续为新增的,设定一次取出最大为100,不够直接执行。否则先执行再继续读队列,如果碰到不是新增的,直接执行。
lucene4.7开发实例,包括索引创建、修改、删除、排序、分页、优化、高亮显示、常见几种分词器等。实例加全jar包
#Lucene和Elasticsearch课程##日程搜索和索引系统架构Lucene,第一步创建文件和索引通过查询提取信息弹性搜索概念简单的配置和集群模式搜索次数REST API 数百种使用jQueryJavaScript 使用Spring Data的Java客户端#...
6.4.1 索引优化 155 6.4.2 查询优化 157 6.4.3 实现时间加权排序 162 6.4.4 实现字词混合索引 163 6.4.5 定制Similarity 170 6.4.6 定制Tokenizer 171 6.5 查询大容量索引 173 6.6 本章小结 174 第7章 用户界面设计...
Solr是Apache下的一个顶级开源项目,采用Java...使用Solr进行创建索引和搜索索引的实现方法很简单,如下:*创建索引:客户端(可以是浏览器可以是Java程序)用POST方法向Solr服务器发送一个描述 Field及其内容的XML文
一个由anjularjs+bootstrap+springMVC搭建的免费开源的API接口、文档管理系统(应用接口管理系统) 修改内容: 1.Lucene索引添加项目ID,解决搜索结果调试按钮点击跳转错误的bug 2.添加文章、评论、数据字段、网页的...
更重要的是,Solr 创建的索引与 Lucene 搜索引擎库完全兼容。 通过对 Solr 进行适当的配置, 某些情况下可能需要进行编码,Solr 可以阅读和使用构建到其他 Lucene 应用程序中的索引。此 外,很多 Lucene 工具(如 Nutch、...
├─补充1:拔高课程(Redis3.0持久化、集群、MySQL5.6优化、Tomcat7优化) │ │ 打开必读.txt │ │ │ ├─课前资料 │ │ ├─MySQL5.6优化 │ │ │ MySql5.6性能优化.docx │ │ │ │ │ ├─Redis集群 │ ...