设为首页 收藏本站
查看: 498|回复: 0

[经验分享] Solr 4.0: Realtime GET

[复制链接]
累计签到:2 天
连续签到:1 天
发表于 2016-12-15 08:53:54 | 显示全部楼层 |阅读模式
  he next functionality I decided to look at, from the upcoming Solr 4.0, is the so called “Realtime Get”. It allows you to see the data even though it was not yet added to the index, thus before the commit operation being sent to Solr. Let’s see how it works.
Some theory
  Data update in Lucene and Solr has one disadvantage – when you submit index updates they can’t be seen until commit operation is run. The problem is that commit is costly in terms of performance and intense commiting may cause performance problems. So, when you need your data to be visible right after being change you may be forced to choose – either performance, or fast updates. In order to address that Lucene and Solr are working towards enabling Near Real Time (NRT) searching. In Lucene we have that possibility, in Solr 4.0 we will also be able to use that and not only that.
Configuration
  In order to use Realtime Get functionality we need to configure the following Solr features:
Transaction log
  The first thing to configure is the transaction log writing. In order to do that you need to add the following to your updateHandler configuration:
1<updateLog>

2  <str name="dir">${solr.data.dir:}</str>

3</updateLog>



  The above entry says, that the directory holding transaction log will be located in the same directory where the index directory is located.
Realtime Get handler
  The second thing that needs to be done, to see the Realtime Get in action, is the appropriate handler configuration (or adding component to your already defined handler). To do that add the following to your solrconfig.xml file:
1<requestHandler name="/get" class="solr.RealTimeGetHandler">

2  <lst name="defaults">

3    <str name="omitHeader">true</str>

4  </lst>

5</requestHandler>



  The above entry it’s nothing unusual – it just add a new request handler implementing solr.RealTimeGetHandler class, which enables checking the transaction log.
Action
  To check how Realtime Get works I decided to do a simple test. The first thing I did is indexing one file (from the ones that are available in the exampledocs directory) with the use of the following bash command:
1curl 'http://localhost:8983/solr/update' -d @hd.xml -H 'Content-type:application/xml'



  Of course I did not send the commit operation after indexing. As we could expect the following query:
1http://localhost:8983/solr/select?q=*:*



  didn’t return search results. So let’s check, if the handler registered as /get will be able to get us some results. In order to do that I send the following query:
1http://localhost:8983/solr/get?id=SP2514N



  And in result I got the following document:
01<?xml version="1.0" encoding="UTF-8"?>

02<response>

03<doc name="doc">

04  <str name="id">SP2514N</str>

05  <str name="name">Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133</str>

06  <str name="manu">Samsung Electronics Co. Ltd.</str>

07  <str name="manu_id_s">samsung</str>

08  <arr name="cat">

09    <str>electronics</str>

10    <str>hard drive</str>

11  </arr>

12  <arr name="features">

13    <str>7200RPM, 8MB cache, IDE Ultra ATA-133</str>

14    <str>NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor</str>

15  </arr>

16  <float name="price">92.0</float>

17  <int name="popularity">6</int>

18  <bool name="inStock">true</bool>

19  <date name="manufacturedate_dt">2006-02-13T15:26:37Z</date>

20  <str name="store">35.0752,-97.032</str></doc>

21</response>



  So Solr returned the result that wasn’t added to the index – nice !
Usage possibilities
  You probably noticed, that in order to fetch a document with /get handler I needed to provide it’s unique identifier (or identifiers list). That’s true, Realtime Get doesn’t support searching, because it was not created to support full searching. This functionality is able to show us the updates of the documents which identifiers are known (so for example the ones in the index) – in example by adding the component used in solr.RealTimeGetHandler to any of your defined handler. And the good news is – you don’t have to worry update performance – solr.RealTimeGet is very fast. So, if one of your problems is frequent updated you can look in the future with a smile DSC0000.gif
Last few words
  The Realtime Get functionality brings new possibilities when it comes to Solr and also on the road to the SolrCloud. With the use of transaction log one can implement automatic cluster node restore or instance NRT instance updates. As you can see Solr 4.0 is not only about search, but also about data store and bringing Solr closer to NoSQL solutions.
  转自:http://solr.pl/en/2012/01/09/solr-4-0-realtime-get-2/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-314470-1-1.html 上篇帖子: solr DataimportHanler fileld 出现null 下篇帖子: Solr 缓存配置(转)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表