• 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

lucene5 实时搜索的更多相关文章

  1. Lucene.net 实现近实时搜索(NRT)和增量索引

    Lucene做站内搜索的时候经常会遇到实时搜索的应用场景,比如用户搜索的功能.实现实时搜索,最普通的做法是,添加新的document之后,调用 IndexWriter 的 Commit 方法把内存中的 ...

  2. Lucene系列-近实时搜索(1)

    近实时搜索(near-real-time)可以搜索IndexWriter还未commit的内容,介于immediate和eventual之间,在数据比较大.更新较频繁的情况下使用.本文主要来介绍下如何 ...

  3. Solr -- 实时搜索

    在solr中,实时搜索有3种方案 ①soft commit,这其实是近实时搜索,不能完全实时. ②RealTimeGet,这是实时,但只支持根据文档ID的查询. ③和第一种类似,只是触发softcom ...

  4. Everything文件名实时搜索||解决局域网文件共享问题

    内容概要:Everything中文版下载地址及使用.用Everything轻松解决局域网文件共享问题.Everything语言设置问题 另:Everything只支持NTFS格式的磁盘(工作原理的缘故 ...

  5. jmeter 实时搜索结果

    因为JMeter 2.13你可以得到实时搜索结果发送到后端通过 后端侦听器 使用潜在的任何后端(JDBC.JMS网络服务,€Š) 通过提供一个实现类 AbstractBackendListenerCl ...

  6. Elasticsearch是一个分布式可扩展的实时搜索和分析引擎,elasticsearch安装配置及中文分词

    http://fuxiaopang.gitbooks.io/learnelasticsearch/content/  (中文) 在Elasticsearch中,文档术语一种类型(type),各种各样的 ...

  7. lucene4.5近实时搜索

    近实时搜索就是他能打开一个IndexWriter快速搜索索引变更的内容,而不必关闭writer,或者向writer提交,这个功能是在2.9版本以后引入的,在以前没有这个功能时,必须调用writer的c ...

  8. 关于lucene的IndexSearcher单实例,对于索引的实时搜索

    Lucene版本:3.0 一般情况下,lucene的IndexSearcher都要写成单实例,因为每次创建IndexSearcher对象的时候,它都需要把索引文件加载进来,如果访问量比较大,而索引也比 ...

  9. 【Lucene】近实时搜索

    近实时搜索:可以使用一个打开的IndexWriter快速搜索索引的变更内容,而不必首先关闭writer,或者向该writer提交:这是2.9版本之后推出的新功能. 代码示例(本例参考<Lucen ...

随机推荐

  1. C++的几种字符类型

    我们在C学过了char字符类型. 在C++中,char是基本的字符类型,但却不仅仅有这一种字符类型! 类型 含义 该类型数据所占的最小比特位数 char 字符 8位(即可表示28个字符) wchar_ ...

  2. 数据结构7——BFS

    一.重拾关键 宽度优先搜索,也有称为广度优先搜索,简称BFS.类似于树的按层次遍历的过程. 初始状态:图G所有顶点均未被访问过,任选一点v. 遍历过程:假设从图中某顶点v出发,在访问了v之后依次访问v ...

  3. Daily Scrum02 11.29

    今天大家都已经开始了进行第二轮迭代的工作!相比第一轮迭代,每个人都已经有了一定开发经验,这次做起来顺手很多.薛神和肖犇的挑战最大,他们需要实现好友功能,手机间的通信.服务器的搭建都是难点,但他们的热情 ...

  4. winform showDialog() 退出问题

    今日发现: 当返回值为Dialog.OK时,会自动退出,不需要this.close().别的返回值仍需要.

  5. lintcode-133-最长单词

    133-最长单词 给一个词典,找出其中所有最长的单词. 样例 在词典 { "dog", "google", "facebook", &quo ...

  6. 牛客网(string::find()函数回忆一下)

    链接:https://www.nowcoder.com/acm/contest/109/B来源:牛客网 给出两个串s和x 定义s中的某一位i为好的位置,当且仅当存在s的子序列 满足y=x且存在j使得i ...

  7. P3539 [POI2012]ROZ-Fibonacci Representation

    题目描述 The Fibonacci sequence is a sequence of integers, called Fibonacci numbers, defined as follows: ...

  8. BZOJ3295: [Cqoi2011]动态逆序对 莫队

    这个用莫队做会被卡,但是我还是...... 收获在于树状数组维护后缀和以及双维排序...... 莫队的时间复杂度比想象中的要好一些.... 然而我还是被卡了...... #include<ios ...

  9. 用PHP迭代器来实现一个斐波纳契数列

    斐波纳契数列通常做法是用递归实现,当然还有其它的方法.这里现学现卖,用PHP的迭代器来实现一个斐波纳契数列,几乎没有什么难度,只是把类里的next()方法重写了一次.注释已经写到代码中,也是相当好理解 ...

  10. shell脚本应用

    解析乱的日志文件到临时文件中,然后用awk  1004  cd /usr/local  1005  ll  1006  cd pttmsg/  1007  ll  1008  cd msgbin-2/ ...