RealTime Get

For index updates to be visible (searchable), some kind of commit must reopen a searcher to a new point-in-time view of the index.

The realtime get feature allows retrieval (by unique-key) of the latest version of any documents without the associated cost of reopening a searcher. This is primarily useful when using Solr as a NoSQL data store and not just a search index.

Real Time Get relies on the update log feature, which is enabled by default and can be configured in solrconfig.xml:

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

Real Time Get requests can be performed using the /get handler which exists implicitly in Solr - see Implicit RequestHandlers - it’s equivalent to the following configuration:

<requestHandler name="/get" class="solr.RealTimeGetHandler">
  <lst name="defaults">
    <str name="omitHeader">true</str>
    <str name="wt">json</str>
    <str name="indent">true</str>

For example, if you started Solr using the bin/solr -e techproducts example command, you could then index a new document (with out committing it) like so:

curl 'http://localhost:8983/solr/techproducts/update/json?commitWithin=10000000' \
  -H 'Content-type:application/json' -d '[{"id":"mydoc","name":"realtime-get test!"}]'

If you do a normal search, this document should not be found yet:


However if you use the Real Time Get handler exposed at /get, you can still retrieve that document:

{"doc":{"id":"mydoc","name":"realtime-get test!", "_version_":1487137811571146752}}

You can also specify multiple documents at once via the ids parameter and a comma separated list of ids, or by using multiple id parameters. If you specify multiple ids, or use the ids parameter, the response will mimic a normal query response to make it easier for existing clients to parse.

For example:

    [ { "id":"mydoc",
        "name":"realtime-get test!",
        "name":"iPod & iPod Mini USB 2.0 Cable",

Real Time Get requests can also be combined with filter queries, specified with an fq parameter, just like search requests:

    [ { "id":"mydoc",
        "name":"realtime-get test!",

Do NOT disable the realtime get handler at /get if you are using SolrCloud otherwise any leader election will cause a full sync in ALL replicas for the shard in question.

Similarly, a replica recovery will also always fetch the complete index from the leader because a partial sync will not be possible in the absence of this handler.