Книга: Apache Solr Search Patterns
Назад: Advanced sharding with SolrCloud
Дальше: Migrating documents to another collection

Asynchronous calls

Since some API calls, such as shard splitting, can take a long time and result in timeouts, we have the option of running a call asynchronously by specifying the async=<request_id> parameter in the URL. <request_id> is any ID that can be used to track the status of a particular API call. The request_id class and the status of the task are stored in ZooKeeper and can be retrieved using the REQUESTSTATUS action on the collections API.

Tip

We can delete and recreate catcollection using the following API calls or URLs:

http://solr1:8080/solr/admin/collections?action=DELETE&name=catcollection http://solr1:8080/solr/admin/collections?action=CREATE&name=catcollection&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=conf1&router.field=cat

catcollection can be populated using docs.csv file provided by the following command:

 java -Dtype=text/csv -Durl=http://solr4:8080/solr/catcollection/update -jar post.jar docs.csv 

To perform splitting using the async parameter, execute the following command:

http://solr1:8080/solr/admin/collections?action=SPLITSHARD&collection=catcollection&split.key=books!&async=1111
Asynchronous calls

We immediately get a response which just shows the requestid that we submitted. The status of the request can be checked by executing the following URL:

http://solr1:8080/solr/admin/collections?action=REQUESTSTATUS&requestid=1111
Asynchronous calls

Here we can see that the status is marked as completed. These requests and their status are stored in ZooKeeper and are not cleaned up automatically. We can clean up the requests by passing requestid as -1:

http://solr1:8080/solr/admin/collections?action=REQUESTSTATUS&requestid=-1
Назад: Advanced sharding with SolrCloud
Дальше: Migrating documents to another collection

Solr
Testing
dosare
121