이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 291. Solr Component
Available as of Camel version 2.9
The Solr component allows you to interface with an Apache Lucene Solr server (based on SolrJ 3.5.0).
Maven users will need to add the following dependency to their pom.xml
for this component:
291.1. URI format 링크 복사링크가 클립보드에 복사되었습니다!
NOTE: solrs and solrCloud are new added since Camel 2.14.
solr://host[:port]/solr?[options] solrs://host[:port]/solr?[options] solrCloud://host[:port]/solr?[options]
solr://host[:port]/solr?[options]
solrs://host[:port]/solr?[options]
solrCloud://host[:port]/solr?[options]
291.2. Solr Options 링크 복사링크가 클립보드에 복사되었습니다!
The Solr component has no options.
The Solr endpoint is configured using URI syntax:
solr:url
solr:url
with the following path and query parameters:
291.2.1. Path Parameters (1 parameters): 링크 복사링크가 클립보드에 복사되었습니다!
Name | Description | Default | Type |
---|---|---|---|
url | Required Hostname and port for the solr server | String |
291.2.2. Query Parameters (13 parameters): 링크 복사링크가 클립보드에 복사되었습니다!
Name | Description | Default | Type |
---|---|---|---|
allowCompression (producer) | Server side must support gzip or deflate for this to have any effect | Boolean | |
connectionTimeout (producer) | connectionTimeout on the underlying HttpConnectionManager | Integer | |
defaultMaxConnectionsPer Host (producer) | maxConnectionsPerHost on the underlying HttpConnectionManager | Integer | |
followRedirects (producer) | indicates whether redirects are used to get to the Solr server | Boolean | |
maxRetries (producer) | Maximum number of retries to attempt in the event of transient errors | Integer | |
maxTotalConnections (producer) | maxTotalConnection on the underlying HttpConnectionManager | Integer | |
requestHandler (producer) | Set the request handler to be used | String | |
soTimeout (producer) | Read timeout on the underlying HttpConnectionManager. This is desirable for queries, but probably not for indexing | Integer | |
streamingQueueSize (producer) | Set the queue size for the StreamingUpdateSolrServer | 10 | int |
streamingThreadCount (producer) | Set the number of threads for the StreamingUpdateSolrServer | 2 | int |
synchronous (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean |
collection (solrCloud) | Set the collection name which the solrCloud server could use | String | |
zkHost (solrCloud) | Set the ZooKeeper host information which the solrCloud could use, such as zkhost=localhost:8123. | String |
291.3. 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.
- the INSERT operations use the CommonsHttpSolrServer
- the INSERT_STREAMING operations use the StreamingUpdateSolrServer (Camel 2.9.2)
Operation | Message body | Description |
---|---|---|
INSERT/INSERT_STREAMING | n/a | adds an index using message headers (must be prefixed with "SolrField.") |
INSERT/INSERT_STREAMING | File | adds an index using the given File (using ContentStreamUpdateRequest) |
INSERT/INSERT_STREAMING | SolrInputDocument | Camel 2.9.2 updates index based on the given SolrInputDocument |
INSERT/INSERT_STREAMING | String XML | Camel 2.9.2 updates index based on the given XML (must follow SolrInputDocument format) |
ADD_BEAN | bean instance | adds an index based on values in an annotated bean |
ADD_BEANS | collection<bean> | Camel 2.15 adds index based on a collection of annotated bean |
DELETE_BY_ID | index id to delete | delete a record by ID |
DELETE_BY_QUERY | query string | delete a record by a query |
COMMIT | n/a | performs a commit on any pending index changes |
ROLLBACK | n/a | performs a rollback on any pending index changes |
OPTIMIZE | n/a | performs a commit on any pending index changes and then runs the optimize command |
291.4. Example 링크 복사링크가 클립보드에 복사되었습니다!
Below is a simple INSERT, DELETE and COMMIT example
A client would simply need to pass a body message to the insert or delete routes and then call the commit route.
template.sendBody("direct:insert", "1234"); template.sendBody("direct:commit", null); template.sendBody("direct:delete", "1234"); template.sendBody("direct:commit", null);
template.sendBody("direct:insert", "1234");
template.sendBody("direct:commit", null);
template.sendBody("direct:delete", "1234");
template.sendBody("direct:commit", null);
291.5. Querying Solr 링크 복사링크가 클립보드에 복사되었습니다!
Currently, this component doesn’t support querying data natively (may be added later). For now, you can query Solr using HTTP as follows:
For more information, see these resources…
291.6. See Also 링크 복사링크가 클립보드에 복사되었습니다!
- Configuring Camel
- Component
- Endpoint
- Getting Started