11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

It is really another endpoint of the Config API instead of a separate API, and has distinct commands. It does not<br />

replace or modify any sections of solrconfig.xml, but instead provides another approach to handling<br />

parameters used in requests. It behaves in the same way as the Config API, by storing parameters in another file<br />

that will be used at runtime. In this case, the parameters are stored in a file named params.json. This file is<br />

kept in ZooKeeper or in the conf directory of a standalone <strong>Solr</strong> instance.<br />

The settings stored in params.json are used at query time to override settings defined in solrconfig.xml in<br />

some cases as described below.<br />

When might you want to use this feature?<br />

To avoid frequently editing your solrconfig.xml to update request parameters that change often.<br />

To reuse parameters across various request handlers.<br />

To mix and match parameter sets at request time.<br />

To avoid a reload of your collection for small parameter changes.<br />

The Request Parameters Endpoint<br />

All requests are sent to the /config/params endpoint of the Config API.<br />

Setting Request Parameters<br />

The request to set, unset, or update request parameters is sent as a set of Maps with names. These objects can<br />

be directly used in a request or a request handler definition.<br />

The available commands are:<br />

set: Create or overwrite a parameter set map.<br />

unset: delete a parameter set map.<br />

update: update a parameter set map. This is equivalent to a map.putAll(newMap) . Both the maps are<br />

merged and if the new map has same keys as old they are overwritten<br />

You can mix these commands into a single request if necessary.<br />

Each map must include a name so it can be referenced later, either in a direct request to <strong>Solr</strong> or in a request<br />

handler definition.<br />

In the following example, we are setting 2 sets of parameters named 'myFacets' and 'myQueries'.<br />

curl http://localhost:8983/solr/techproducts/config/params -H<br />

'Content-type:application/json' -d '{<br />

"set":{<br />

"myFacets":{<br />

"facet":"true",<br />

"facet.limit":5}},<br />

"set":{<br />

"myQueries":{<br />

"defType":"edismax",<br />

"rows":"5",<br />

"df":"text_all"}}<br />

}'<br />

In the above example all the parameters are equivalent to the "defaults" in solrconfig.xml. It is possible to add<br />

invariants and appends as follows<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

490

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!