• openIfChanged

    public static DirectoryReader openIfChanged(DirectoryReader oldReader)
    throws IOException
    If the index has changed since the provided reader was opened, open and return a new reader; else, return null. The new reader, if not null, will be the same type of reader as the previous one, ie an NRT reader will open a new NRT reader, a MultiReader will open a new MultiReader, etc.

    This method is typically far less costly than opening a fully new DirectoryReader as it shares resources (for example sub-readers) with the provided DirectoryReader, when possible.

    The provided reader is not closed (you are responsible for doing so); if a new reader is returned you also must eventually close it. Be sure to never close a reader while other threads are still using it; see SearcherManager to simplify managing this.

    Returns:
    null if there are no changes; else, a new DirectoryReader instance which you must eventually close
    Throws:
    CorruptIndexException - if the index is corrupt
    IOException - if there is a low-level IO error

如果旧reader是一个NRT reader, 使用此方法重新打开reader可以发现writer的修改,而不需要提交

  • openIfChanged

    public static DirectoryReader openIfChanged(DirectoryReader oldReader,
    IndexWriter writer)
    throws IOException
    Expert: If there changes (committed or not) in the IndexWriter VS what the provided reader is searching, then open and return a new IndexReader searching both committed and uncommitted changes from the writer; else, return null (though, the current implementation never returns null).

    This provides "near real-time" searching, in that changes made during an IndexWriter session can be quickly made available for searching without closing the writer nor calling IndexWriter.commit().

    It's near real-time because there is no hard guarantee on how quickly you can get a new reader after making changes with IndexWriter. You'll have to experiment in your situation to determine if it's fast enough. As this is a new and experimental feature, please report back on your findings so we can learn, improve and iterate.

    The very first time this method is called, this writer instance will make every effort to pool the readers that it opens for doing merges, applying deletes, etc. This means additional resources (RAM, file descriptors, CPU time) will be consumed.

    For lower latency on reopening a reader, you should call IndexWriterConfig.setMergedSegmentWarmer(org.apache.lucene.index.IndexWriter.IndexReaderWarmer) to pre-warm a newly merged segment before it's committed to the index. This is important for minimizing index-to-search delay after a large merge.

    If an addIndexes* call is running in another thread, then this reader will only search those segments from the foreign index that have been successfully copied over, so far.

    NOTE: Once the writer is closed, any outstanding readers may continue to be used. However, if you attempt to reopen any of those readers, you'll hit an AlreadyClosedException.

    Parameters:
    writer - The IndexWriter to open from
    Returns:
    DirectoryReader that covers entire index plus all changes made so far by this IndexWriter instance, or null if there are no new changes
    Throws:
    IOException - if there is a low-level IO error
    WARNING: This API is experimental and might change in incompatible ways in the next release.
  • openIfChanged

    public static DirectoryReader openIfChanged(DirectoryReader oldReader,
    IndexWriter writer,
    boolean applyAllDeletes)
    throws IOException
    Expert: Opens a new reader, if there are any changes, controlling whether past deletions should be applied.
    Parameters:
    writer - The IndexWriter to open from
    applyAllDeletes - If true, all buffered deletes will be applied (made visible) in the returned reader. If false, the deletes are not applied but remain buffered (in IndexWriter) so that they will be applied in the future. Applying deletes can be costly, so if your app can tolerate deleted documents being returned you might gain some performance by passing false.
    Throws:
    IOException - if there is a low-level IO error
    See Also:
    openIfChanged(DirectoryReader,IndexWriter)
    WARNING: This API is experimental and might change in incompatible ways in the next release.

http://my.oschina.net/MrMichael/blog/220723

最新文章

  1. [Nginx笔记]关于线上环境CLOSE_WAIT和TIME_WAIT过高
  2. 利用Docker技术实现UDP广播效果(网络编程python版)
  3. android 获取文件夹、文件的大小 以B、KB、MB、GB 为单位
  4. JS+JQ手风琴效果
  5. 开发与测试整体过程中的Git分支merge流程
  6. 浅谈javascript中stopImmediatePropagation函数和stopPropagation函数的区别
  7. install redis
  8. panda库------对数据进行操作---合并,转换,拼接
  9. 安装scrapy框架的常见问题及其解决方法
  10. laravel and lumen 软删除操作
  11. aforge 学习-命名空间中文理解
  12. spark中map与flatMap的区别
  13. 一道关于js声明变量,var和let的面试题
  14. python的四大函数讲解
  15. C# 解决请求被中止:无法建立SSL / TLS安全通道问题
  16. docekr-image的区别和container;docker run和start,create
  17. PTA (Advanced Level) 1003 Emergency
  18. Redis五种数据类型-设置key的过期时间
  19. 创建一个接口Shape,其中有抽象方法area,类Circle 、Rectangle实现area方法计算其面积并返回。又有Star实现Shape的area方法,其返回值是0,Star类另有一返回值boolean型方法isStar;在main方法里创建一个Vector,根据随机数的不同向其中加入Shape的不同子类对象(如是1,生成Circle对象;如是2,生成Rectangle对象;如是3,生成S
  20. [SoapUI] Mock Service

热门文章

  1. 数论3——gcd&&lcm
  2. java计算两个日期之间的相隔天数
  3. 7forJava
  4. scrapy使用记录
  5. Java IO 之 System类
  6. java高精度类尝试
  7. fzu 2246(ac 自动机)
  8. 获取Parameter参数值,方便调试使用
  9. sshd_conf配置
  10. iebackground+icon图标兼容