索引文件的多个段可以合并成一个或少量几个。这样将节省一部分硬盘空间,更重要的是,它可以加快搜索速度。需要注意的是,是加快搜索速度,并非加快索引速度。方法很简单:
optimize(int maxNumSegments, boolean doWait);
maxNumSegments 代表合并后可能存在的最大段数,也就是传入5,合并完可能存在1或2或3或4或5个段;另外就是,合并成1个段比合并成5个更耗时。
doWait 表示是否等待。如果传入false,则该方法会立即返回,索引文件的合并工作将在后台执行。
只提供一个方法是不是显得太单调了?Lucene比较蛋疼的为我们设置了两个特殊状态:maxNumSegments为1 和 doWait为true。下面是这两种的组合:
optimize(boolean doWait); //该方法的maxNumSegments为1,你可以指定doWait
optimize(int maxNumSegments); //该方法的doWait为true,你可以指定maxNumSegments
optimize(); //该方法的maxNumSegments为1,doWait为true
好了,这一节也非常简单,在结束之前提醒大家一下:在做Optimizing的时候,最好保证磁盘空间足够大,大到是当前索引文件的3倍!具体原因先不细谈了。
分享到:
相关推荐
Pub Date: 2018 Learn how Java principles and technology make the best use of modern hardware and operating systems Explore several performance tests and common anti-patterns that can vex your team ...
优化Flash性能 Optimizing Flash performance
LB +-树:优化3DXPoint内存上的持久索引性能
[OPTIMIZING]OPTIMIZING_CPP
Optimizing parallel reduction in CUDA 规约优化文档
[OPTIMIZING]OPTIMIZING_ASSEMBLY
optimizing C++ C++优化-英文版
Optimizing Java Practical Techniques for Improved 完整版,不是early release
Optimizing Aerodynamic Design Problems
信息安全_数据安全_Automation_vs_Human_Eyes:Optimizing_Hu 边界防御 应用审计 web安全 云安全 用户隐私
Building an Optimizing Compiler Building an Optimizing Compiler Building an Optimizing Compiler
Optimizing Plane Routes 优化飞机航线.doc
文章分析了能源枢纽如何通过集成多种能源转换技术,实现对电力和热力市场的灵活响应和优化运营。内容涵盖了能源枢纽的基本工作原理、市场运作机制、经济效益分析以及政策和法规的影响。适用人群包括能源行业的专业...
Securing And Optimizing Linux
Optimizing compilers for modern architectures: a dependence based approach
本书为使用英特尔流行的微处理器产品线的设备汇编了与Android应用程序开发相关的最佳实践和过程。
C++优化系列 - 2.Optimizing subroutines in assembly language An optimization guide for x86 platforms
为C ++程序员提供了一种实用的,实际的程序优化方法。
This 3rd edition of the very popular title "Securing & Optimizing Linux" looks for security measures that go beyond firewalls and intrusion detection systems to anticipate and protect against upcoming...
High Performance Spark: Best Practices for Scaling and Optimizing Apache Spark by Holden Karau English | 25 May 2017 | ASIN: B0725YT69J | 358 Pages | AZW3 | 3.09 MB Apache Spark is amazing when ...