SOLR-Real-time search

Source: Internet
Author: User
Tags solr solr documentation

In Solr, there are 3 options for real-time search

①soft commit, which is actually near real-time search, cannot be completely real-time. ②realtimeget, this is real-time, but only supports queries based on the document ID. ③ and the first one are similar, just trigger softcommit. In fact, both real-time (②) and near real-time (①③) are two kinds.

solr4.0 using NRT method and required configuration after

Scenario 1

Use soft commit to achieve near real-time search results.

In order to use soft commit, you need to configure Solrconfig.xml. Two of these places need to be modified

<autocommit>      <Maxdocs>10000</Maxdocs> <!--Maximum uncommited docs before autocommit triggered -      <MaxTime>15000</MaxTime> <!--maximum time (in MS) after adding a doc before an autocommit is triggered -      <Opensearcher>False</Opensearcher> <!--SOLR 4.0.  Optionally don ' t open a searcher on hard commit. This was useful to minimize the size of transaction logs that keep track of uncommitted updates.  -</autocommit>

It is necessary to change the hard commit's opensearcher to true. Hard commit time is set according to your system's load-carrying capacity and needs. Because the hard commit action is larger, the performance has a greater impact. The principle is slightly longer, but not too long, to avoid a sudden power outage leading to a large amount of data loss (hard commit data is in memery).

<!--softautocommit Perform a ' soft ' commit automatically under certain conditions.         This commits avoids ensuring that the data is synched to disk. Maxdocs-maximum number of documents to add since the last soft commit before automaticly triggering a         New Soft commit. Maxtime-maximum amount of time in MS so is allowed-pass since a document was added before Automat      icly triggering a new soft commit.  -     <Autosoftcommit>       <MaxTime>2000</MaxTime>     </Autosoftcommit>

Open the Soft commit (the default configuration notes the node), where you want to search within seconds, where my settings are 2s. Can be set as needed, the smaller the value NRT the better the effect, on the contrary, will have a performance impact. If the index request volume is not particularly large, you can set the value to a small point, for example 1000. Less than 1000 is not recommended and less than 1000 is meaningless.

After setting a A, a, you can search through the ordinary searchhandler. The Searchhandler rest interface of SOLR's default configuration has "/select" "/query" "/browse".

It is important to note that when the amount of index requests is huge, SOLR does not necessarily guarantee that you will be able to immediately search for the latest documents in the time you set, usually with a second-level delay.

Scenario 2

You need to configure Solrconfig.xml. Two of these places need to be modified

<autocommit>      <Maxdocs>10000</Maxdocs> <!--Maximum uncommited docs before autocommit triggered -      <MaxTime>15000</MaxTime> <!--maximum time (in MS) after adding a doc before an autocommit is triggered -      <Opensearcher>False</Opensearcher> <!--SOLR 4.0.  Optionally don ' t open a searcher on hard commit. This was useful to minimize the size of transaction logs that keep track of uncommitted updates.  -</autocommit>

Also configure the Solrconfig.xml Realtimegethandler. According to the SOLR documentation. The search handler interface is "/get". The interface uses a specific component, realtimegetcomponent, which will solrcore the Getrealtimesearcher () method, which will search for updatelog first and then do a normal search.

Scenario 3

The 3rd method of using NRT still requires the configuration of item A in NRT1. This time using the ordinary searchhandler to achieve NRT. Take advantage of SOLR's commit and Commitwithin. This is accomplished by explicitly sending a commit or Commitwithin command after each index of the document. This also allows you to search for the data just indexed immediately. Due to the need to send command network, time uncertainty, the overall speed is not as NRT1. Here commit is the hard commit request, the method is Commit=true;commitwithin for the softcommit request, and the method is commitwithin=2000. As can be seen in the previous statement is also a commit, is to use Commitwithin will be able to search the new document faster, here is to complete the softcommit in 2s. This method is flexible and suitable for use in some special cases.

In conclusion, although we can achieve NRT through different means (including disguised means NRT3). But the way to configure Softcommit in NRT1 is the best choice, and this is the value of its existence. However, in some special application scenarios, NRT3 can be used as needed. For example, the index is frequent and the search volume is small.

SOLR-Real-time search

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.