Solr 5.1 Features

Solr 5.1 has been released! Here’s an overview of how to use some of the new features.

Also see Solr download links and upcoming features of the next Solr release.

New Facet Module

The new facet module has a native JSON Facet API,
first-class support for statistics and analytics via facet functions (aggregations), and supports unlimited nesting of facets within other facets via sub-facets.

One can calculate statistics such as averages, number of unique values (distinct values), and percentiles over each facet bucket (groups of documents), and even sort facet buckets by any calculated metrics.

New JSON Request API

A JSON Request API that allows passing a full Solr query request in JSON.


curl http://localhost:8983/solr/query -d '
  query : "*:*",
  filter : [
  offset : 0,
  limit : 5,
  fields : ["title","author"],  // we could also use the string form "title,author"
  sort : "sequence_i desc",
  facet : {  // the JSON Facet API is nicely integrated as well
    avg_price : "avg(price)",
    median_price : "percentile(price,50)",
    top_authors : {terms : author}

Parameter Substitution / Macro Expansion

Parameter substitution is now done across the entire query request. It supports default values, multiple levels of indirection, and it even works within the body of a JSON request. This can also be viewed as a powerful form of request templates.


q=price:[ ${low} TO ${high} ]

Parameters can also be passed in the params block of a JSON request.

Constant Score Query Syntax

Syntax within the standard lucene/solr query parser for constant score queries quit the general form of <clause>^=<constant_score>. Think of a query boost with ^ replaced with ^=.

q=(color:blue color:green)^=2.0 text:shoes

Streaming API

There is a new general purpose parallel computing framework for SolrCloud. The Streaming API is (currently) a Java API that can do streaming aggregations (like sum and average) and streaming transformations (like group-by and join).

Admin UI Segment Info

The admin UI can show segment info such as size, number of docs, and number of deletions for each segment in the index.
For the “demo” collection, simply point your browser at
Or click on the “Segments Info” link in the admin UI after you select the core/collection you are interested in.

Schema API can remove and replace fields

The bulk schema API how has the ability to replace or remove fields, fieldTypes, dynamic fields, and copy fields.

Example of adding a field (this was already possible):

curl http://localhost:8983/solr/demo/schema -d '
     "name" : "powerLevel",
     "type" : "int",
     "indexed" : true,
     "stored" : true

Now we can replace the field definition:

curl http://localhost:8983/solr/demo/schema -d '
     "name" : "powerLevel",
     "type" : "int",
     "indexed" : false,
     "stored" : true

We can verify that Solr now has the updated field definition with

curl http://localhost:8983/solr/demo/schema/fields/powerLevel

And solr returns:


And lastly, we can delete the field definition with

curl http://localhost:8983/solr/demo/schema -d '
  "delete-field":{ "name" : "powerLevel" }

Spatial Heatmap Faceting

Solr can now execute a two dimensional facet on RPT field types (Spatial Recursive Prefix Tree).

Parameters Example:

&facet.heatmap.geom=["-180 -90" TO "180 90"]

The facet.heatmap.format=ints2D parameter causes a 2D array of counts to be returned:

"counts_ints2D":[[4, 0, 1, 3, ....],[2, 0, 1, 2, ...],...]

If facet.heatmap.format=png is passed instead, a basic base64-encoded PNG (picture) will be returned of the heatmap grid.

Real-Time Get in SolrJ

There is now an explicit API in SolrJ to use Real-time Get

HttpSolrClient client = new HttpSolrClient("http://localhost:8983/solr/demo");

SolrDocument sdoc = client.getById("book1");
System.out.println("I found book " + sdoc);

client.close(); // shut down the client when we are done

StatsComponent Enable/disable individual stats

Localparams may now be used to selectively enable or disable specific stats in the StatsComponent.
Example: stats.field={!min=true max=true}field_name


Both the new facet module and the stats component gained support for percentiles.

json.facet={ median_age : "percentile(age,50)" } 

Configuration API expansion

Many additional configuration items can now be managed via the Config API.
This includes managing named components such as requestHandler, queryParser, queryResponseWriter, valueSourceParser, transformer, and queryConverter.

Changes do not directly change solrconfig.xml, but instead are reflected in configoverlay.json which override settings in solrconfig.xml.

Upload config sets to zookeeper with CloudSolrClient

Named config sets (schema.xml, solrconfig,xml, etc) are referenced by name when creating new collections in SolrCloud.
These config sets may now be uploaded and downloaded via SolrJ to and from the local filesystem. The following methods were added to CloudSolrClient:

  public void uploadConfig(Path configPath, String configName);
  public void downloadConfig(String configName, Path downloadPath);

API to add JAR to classpath

There is a new API to add a jar to a collection’s classpath (as well as update and delete a jar).
Components that depend on such a jar should have a new attribute called runtimeLib set to true since a separate classloader is used for these jars.

Example of uploading a jar:

curl http://localhost:8983/solr/demo/config -d '{
"add-runtimelib" : {"name": "jarname" , "version":2 }

Example registering a new value source parser using a class in the jar:

curl http://localhost:8983/solr/demo/config -d '{
  "create-valuesourceparser" : {
    "name": "nvl",
    "runtimeLib" : true, 
    "class" : " , 
    "nvlFloatValue" : 0.0