11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Then at query time, you include the prefix(es) into your query with the _route_ parameter (i.e., q=solr&_rout<br />

e_=IBM!) to direct queries to specific shards. In some situations, this may improve query performance because<br />

it overcomes network latency when querying all the shards.<br />

The _route_ parameter replaces shard.keys, which has been deprecated and will be removed in a<br />

future <strong>Solr</strong> release.<br />

The compositeId router supports prefixes containing up to 2 levels of routing. For example: a prefix routing<br />

first by region, then by customer: "USA!IBM!12345"<br />

Another use case could be if the customer "IBM" has a lot of documents and you want to spread it across<br />

multiple shards. The syntax for such a use case would be : "shard_key/num!document_id" where the /num is the<br />

number of bits from the shard key to use in the composite hash.<br />

So "IBM/3!12345" will take 3 bits from the shard key and 29 bits from the unique doc id, spreading the tenant<br />

over 1/8th of the shards in the collection. Likewise if the num value was 2 it would spread the documents across<br />

1/4th the number of shards. At query time, you include the prefix(es) along with the number of bits into your<br />

query with the _route_ parameter (i.e., q=solr&_route_=IBM/3! ) to direct queries to specific shards.<br />

If you do not want to influence how documents are stored, you don't need to specify a prefix in your document ID.<br />

If you created the collection and defined the "implicit" router at the time of creation, you can additionally define a<br />

router.field parameter to use a field from each document to identify a shard where the document belongs. If<br />

the field specified is missing in the document, however, the document will be rejected. You could also use the _r<br />

oute_ parameter to name a specific shard.<br />

Shard Splitting<br />

When you create a collection in <strong>Solr</strong>Cloud, you decide on the initial number shards to be used. But it can be<br />

difficult to know in advance the number of shards that you need, particularly when organizational requirements<br />

can change at a moment's notice, and the cost of finding out later that you chose wrong can be high, involving<br />

creating new cores and re-indexing all of your data.<br />

The ability to split shards is in the Collections API. It currently allows splitting a shard into two pieces. The<br />

existing shard is left as-is, so the split action effectively makes two copies of the data as new shards. You can<br />

delete the old shard at a later time when you're ready.<br />

More details on how to use shard splitting is in the section on the Collections API.<br />

Ignoring Commits from Client Applications in <strong>Solr</strong>Cloud<br />

In most cases, when running in <strong>Solr</strong>Cloud mode, indexing client applications should not send explicit commit<br />

requests. Rather, you should configure auto commits with openSearcher=false and auto soft-commits to<br />

make recent updates visible in search requests. This ensures that auto commits occur on a regular schedule in<br />

the cluster. To enforce a policy where client applications should not send explicit commits, you should update all<br />

client applications that index data into <strong>Solr</strong>Cloud. However, that is not always feasible, so <strong>Solr</strong> provides<br />

the IgnoreCommitOptimizeUpdateProcessorFactory, which allows you to ignore explicit commits and/or optimize<br />

requests from client applications without having refactor your client application code. To activate this request<br />

processor you'll need to add the following to your solrconfig.xml:<br />

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

549

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

Saved successfully!

Ooh no, something went wrong!