...
name | default value | description |
---|---|---|
maxRetries | 0 | maximum number of retries to attempt in the event of transient errors |
soTimeout | 1000 | read timeout on the underlying HttpConnectionManager. This is desirable for queries, but probably not for indexing |
connectionTimeout | 100 | connectionTimeout on the underlying HttpConnectionManager |
defaultMaxConnectionsPerHost | 2 | maxConnectionsPerHost on the underlying HttpConnectionManager |
maxTotalConnections | 20 | maxTotalConnection on the underlying HttpConnectionManager |
followRedirects | false | indicates whether redirects are used to get to the Solr server |
allowCompression | false | server side must support gzip or deflate for this to have any effect |
requestHandler | /update (xml) | set the request handler to be used |
Message Operations
The following Solr operations are currently supported. Simply set an exchange header with a key of "SolrOperation" and a value set to one of the following. Some operations also require the message body to be set.
...
Example
Below is a simple INSERT example in Java and Spring XML.and COMMIT example
Code Block | ||||
---|---|---|---|---|
| ||||
from("direct:startinsert") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT)) .setHeader(SolrConstants.FIELD + "id", body()) .to("solr://localhost:8983/solr"); from("direct:commit") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_COMMIT)) .to("solr://localhost:8983/solr"); |
Code Block | ||||
---|---|---|---|---|
| ||||
<route> <from uri="direct:startinsert"/> <setHeader headerName="SolrOperation"> <constant>INSERT</constant> </setHeader> <setHeader headerName="SolrField.id"> <simple>${body}</simple> </setHeader> <to uri="solr://localhost:8983/solr"/> </route> <route> <from uri="direct:commit"/> <setHeader headerName="SolrOperation"> <constant>COMMIT</constant> </setHeader> <to uri="solr://localhost:8983/solr"/> </route> |
A client would simply need to pass a body message to this route as followsthe insert route and then call the commit route.
Code Block | ||||
---|---|---|---|---|
| ||||
template.sendBody("direct:startinsert", "1234"); "value1" template.sendBody("direct:commit", null); |
Querying Solr
Currently, this component doesn't support querying data natively (will may be added later). For now, you can query Solr in a route using HTTP. TODO: add a simple example to retrieve the data inserted above. as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
//define the route to perform a basic query
from("direct:querySolr")
.recipientList(simple("http://localhost:8983/solr/select/?q=${body}"))
.convertBodyTo(String.class);
...
//query for an id of '1234'
String responseXml = (String) template.requestBody("direct:querySolr", "id:1234");
|
For more information, see these resources...
...