[CONF] Apache Camel > Solr
willem jiang edited the page: Solr Comment: CAMEL-6827 ... Maven users will need to add the following dependency to their pom.xml for this component: Code Block xml org.apache.camel camel-solr x.x.x URI format NOTE: solrs and solrCloud are new added since Camel 2.14. Code Block solr://host[:port]/solr?[options] solrs://host[:port]/solr?[options] solrCloud://host[:port]/solr?[options] Endpoint Options The following SolrServer options may be configured on the Solr endpoint. name default value description maxRetries 0
[CONF] Apache Camel > Solr
Solr Page edited by Ben O'Day Comment: added delete example Changes (5) ... h3. Example Below is a simple INSERT, DELETE and COMMIT example {code:java} ... .to("solr://localhost:8983/solr"); from("direct:delete") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_DELETE_BY_ID)) .to("solr://localhost:8983/solr"); from("direct:commit") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_COMMIT)) ... DELETE_BY_ID ... {code} A client would simply need to pass a body message to the insert route or delete routes and then call the commit route. {code:java} template.sendBody("direct:insert", "1234"); template.sendBody("direct:commit", null); template.sendBody("direct:delete", "1234"); template.sendBody("direct:commit", null); {code} ... Full Content Solr Component Available as of Camel 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: org.apache.camel camel-solr x.x.x URI format solr://host[:port]/solr?[options] Endpoint Options The following SolrServer options may be configured on the Solr endpoint. 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 streamingThreadCount 2 Camel 2.9.2 set the number of threads for the StreamingUpdateSolrServer streamingQueueSize 10 Camel 2.9.2 set the queue size for the StreamingUpdateSolrServer 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 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 Example Below is a simple INSERT, DELETE and COMMIT example from("direct:insert") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT)) .setHeader(SolrConstants.FIELD + "id", body()) .to("solr://localhost:8983/solr"); from("direct:delete") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_DELETE_BY_ID)) .to("solr://localhost:8983/solr"); from("direct:commit") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_COMMIT)) .to("solr://localhost:8983/solr"); "direct:insert"/> "SolrOperation"> INSERT "SolrField.id"> ${body} "solr://localhost:8983/solr"/> "direct:delete"/> "SolrOperation"> DELETE_BY_ID "solr://localhost:8983/solr"/> "direct:commit"/> "SolrOperation"> COMMIT "solr://localhost:8983/solr"/> A client would simply need to pass a body message to the insert or delete routes and
[CONF] Apache Camel > Solr
Solr Page edited by Ben O'Day Comment: updated per CAMEL-5071 Changes (6) ... 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|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.html] * the INSERT_STREAMING operations use the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html] (*Camel 2.10*) ||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.10* adds an updates index based on the given SolrInputDocument| |INSERT_STREAMING|n/a|*Camel 2.10* uses the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html] to add an index using message headers (must be prefixed with "SolrField.")| |INSERT_STREAMING|File|*Camel 2.10* uses the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html] to add an index using the given File (using ContentStreamUpdateRequest)| |INSERT_STREAMING|SolrInputDocument|*Camel 2.10* uses the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html] to add an index based on the given SolrInputDocument| |INSERT/INSERT_STREAMING|String XML|*Camel 2.10* 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|http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr]| |DELETE_BY_ID|index id to delete|delete a record by ID| ... Full Content Solr Component Available as of Camel 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: org.apache.camel camel-solr x.x.x URI format solr://host[:port]/solr?[options] Endpoint Options The following SolrServer options may be configured on the Solr endpoint. 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 streamingThreadCount 2 Camel 2.10 set the number of threads for the StreamingUpdateSolrServer streamingQueueSize 10 Camel 2.10 set the queue size for the StreamingUpdateSolrServer 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.10) 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.10 updates index based on the given SolrInputDocument INSERT/INSERT_STREAMING String XML Camel 2.10 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 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 OPTI
[CONF] Apache Camel > Solr
Solr Page edited by Ben O'Day Comment: updated per CAMEL-4880/4881 Changes (5) ... *Available as of Camel 2.9* The Solr component allows you to interface with an [Apache Lucene Solr|http://lucene.apache.org/solr/] server (based on SolrJ 3.5.0). Maven users will need to add the following dependency to their {{pom.xml}} for this component: ... |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| |streamingThreadCount|2|*Camel 2.10* set the number of threads for the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html]| |streamingQueueSize|10|*Camel 2.10* set the queue size for the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html]| h3. Message Operations ... ||operation ||message body ||description| |INSERT|n/a|insert a new record based on headers values (headers must be prefixed with "SolrField.")| |INSERT|empty|adds an index using message headers (must be prefixed with "SolrField.")| |INSERT|SolrInputDocument|*Camel 2.10* adds an index based on the given SolrInputDocument| |INSERT_STREAMING|empty|*Camel 2.10* uses the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html] to add an index using message headers (must be prefixed with "SolrField.")| |INSERT_STREAMING|SolrInputDocument|*Camel 2.10* uses the [StreamingUpdateSolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.html] to add an index based on the given SolrInputDocument| |ADD_BEAN|bean instance|insert a new record instance|adds an index based on values in an [annotated bean|http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr]| |DELETE_BY_ID|index id to delete|delete a record by ID| |DELETE_BY_QUERY|query string|delete a record by a query| ... Full Content Solr Component Available as of Camel 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: org.apache.camel camel-solr x.x.x URI format solr://host[:port]/solr?[options] Endpoint Options The following SolrServer options may be configured on the Solr endpoint. 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 streamingThreadCount 2 Camel 2.10 set the number of threads for the StreamingUpdateSolrServer streamingQueueSize 10 Camel 2.10 set the queue size for the StreamingUpdateSolrServer 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. operation message body description INSERT empty adds an index using message headers (must be prefixed with "SolrField.") INSERT SolrInputDocument Camel 2.10 adds an index based on the given SolrInputDocument INSERT_STREAMING empty Camel 2.10 uses the StreamingUpdateSolrServer to add an index using message headers (must be prefixed with "SolrField.") INSERT_STREAMING SolrInputDocument Camel 2.10 uses the StreamingUpdateSolrServer to add an index based on the given SolrInputDocument ADD_BEAN bean instance adds an index based on values in an 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 comma
[CONF] Apache Camel > Solr
Solr Page edited by Ben O'Day Comment: updated insert example and added basic query example Changes (15) ... |requestHandler|/update (xml)|set the request handler to be used| h3. 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. ... h3. Example Below is a simple INSERT example in Java and Spring XML. Below is a simple INSERT and COMMIT example {code:java} from("direct:start") from("direct:insert") .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} {code:xml} uri="direct:start"/> uri="direct:insert"/> INSERT ... COMMIT {code} A client would simply need to pass a body message to this route as follows. A client would simply need to pass a body message to the insert route and then call the commit route. {code:java} template.sendBody("direct:start", "value1"); template.sendBody("direct:insert", "1234"); template.sendBody("direct:commit", null); {code} h3. Querying Solr Currently, this component doesn't support querying data (will be added later). For now, you can query Solr in a route using [HTTP]. Currently, this component doesn't support querying data natively (may be added later). For now, you can query Solr using [HTTP] as follows: TODO: add a simple example to retrieve the data inserted above. {code:java} //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"); {code} For more information, see these resources... ... Full Content Solr Component Available as of Camel 2.9 The Solr component allows you to interface with an Apache Lucene Solr server. Maven users will need to add the following dependency to their pom.xml for this component: org.apache.camel camel-solr x.x.x URI format solr://host[:port]/solr?[options] Endpoint Options The following SolrServer options may be configured on the Solr endpoint. 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. operation message body description INSERT n/a insert a new record based on headers values (headers must be prefixed with "SolrField.") ADD_BEAN bean instance insert a new record based on values in an 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 Example Below is a simple INSERT and COMMIT example from("direct:insert") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT)) .setHeader(SolrConstants.FIELD + "id", body()) .to("solr://lo
[CONF] Apache Camel > Solr
Solr Page edited by Ben O'Day Comment: added solr endpoint options info and enhanced operations details Changes (11) ... *Available as of Camel 2.9* The Solr component allows you to interface with an [Apache Lucene Solr|http://lucene.apache.org/solr/] server. Maven users will need to add the following dependency to their {{pom.xml}} for this component: ... {code} h3. Endpoint Options The following [SolrServer|http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.html] options may be configured on the Solr endpoint. ||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|true|server side must support gzip or deflate for this to have any effect| |requestHandler|/update (xml)|set the request handler to be used| h3. Operations The following operations are currently supported. The header SolrConstants.OPERATION is required to be set to one of the following. 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. ||operation ||message body value ||description| |INSERT|N/A|insert |INSERT|n/a|insert a new record based on headers values (headers must be prefixed with "SolrField.")| |ADD_BEAN|bean instance|insert a new record based on values in an [annotated bean|http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr]| |DELETE_BY_ID|index id to delete|delete a record by ID| |DELETE_BY_QUERY|query to use|delete string|delete a record by a query| |COMMIT|N/A|performs |COMMIT|n/a|performs a commit on any pending index changes| |ROLLBACK|N/A|performs |ROLLBACK|n/a|performs a rollback on any pending index changes| |OPTIMIZE|N/A|performs |OPTIMIZE|n/a|performs a commit on any pending index changes and then runs the optimize command| h3. Example ... Below is a simple INSERT example in Java and Spring XML. {code:java} from("direct:start") ... A client would simply need to pass a body message to this route as follows. {code:java} template.sendBody("direct:start", "value1"); ... Full Content Solr Component Available as of Camel 2.9 The Solr component allows you to interface with an Apache Lucene Solr server. Maven users will need to add the following dependency to their pom.xml for this component: org.apache.camel camel-solr x.x.x URI format solr://host[:port]/solr?[options] Endpoint Options The following SolrServer options may be configured on the Solr endpoint. 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 true server side must support gzip or deflate for this to have any effect requestHandler /update (xml) set the request handler to be used 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. operation message body description INSERT n/a insert a new record based on headers values (headers must be prefixed with "SolrField.") ADD_BEAN bean instance insert a new record based on values in an annotated bean DELETE_BY_ID index id to delete delete a record by ID DELETE_BY_QUERY query string delet
[CONF] Apache Camel > Solr
Solr Page edited by Ben O'Day Comment: added operations table and examples Changes (10) ... *Available as of Camel 2.9* The Solr component allows interfacing you to interface with an Apache Lucene Solr server. Maven users will need to add the following dependency to their {{pom.xml}} for this component: ... {code} solr://host[:port]/solr?[options] {code} h3. oOperations [todo] The following operations are currently supported. h3. example ||operation ||description| |INSERT|insert a new record based on headers values (headers must be prefixed with "SolrField.")| |ADD_BEAN|insert a new record based on values in an [annotated bean|http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr]| |DELETE_BY_ID|delete a record by ID| |DELETE_BY_QUERY|delete a record by a query| |COMMIT|performs a commit on any pending index changes| |ROLLBACK|performs a rollback on any pending index changes| |OPTIMIZE|performs a commit on any pending index changes and then runs the optimize command| [todo] h3. Example Below is a simple INSERT example in Java and Spring XML. {code:java} from("direct:start") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT)) .setHeader(SolrConstants.FIELD + "id", body()) .to("solr://localhost:8983/solr"); {code} {code:xml} INSERT ${body}{code} A client would simply need to pass a String body message to this route as follows. {code:java} template.sendBody("direct:start", "value1"); {code} h3. Querying Solr Currently, this component doesn't support querying data (will 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.For more information, see these resources... [Solr Query Tutorial|http://lucene.apache.org/solr/tutorial.html#Querying+Data] [Solr Query Syntax|http://wiki.apache.org/solr/SolrQuerySyntax] {include:Endpoint See Also} Full Content Solr Component Available as of Camel 2.9 The Solr component allows you to interface with an Apache Lucene Solr server. Maven users will need to add the following dependency to their pom.xml for this component: org.apache.camel camel-solr x.x.x URI format solr://host[:port]/solr?[options] Operations The following operations are currently supported. operation description INSERT insert a new record based on headers values (headers must be prefixed with "SolrField.") ADD_BEAN insert a new record based on values in an annotated bean DELETE_BY_ID delete a record by ID DELETE_BY_QUERY delete a record by a query COMMIT performs a commit on any pending index changes ROLLBACK performs a rollback on any pending index changes OPTIMIZE performs a commit on any pending index changes and then runs the optimize command Example Below is a simple INSERT example in Java and Spring XML. from("direct:start") .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT)) .setHeader(SolrConstants.FIELD + "id", body()) .to("solr://localhost:8983/solr"); "direct:start"/> "SolrOperation"> INSERT "SolrField.id"> ${body} "solr://localhost:8983/solr"/> A client would simply need to pass a String body message to this route as follows. template.sendBody("direct:start", "value1"); Querying Solr Currently, this component doesn't support querying data (will 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. For more information, see these resources... Solr Query Tutorial Solr Query Syntax See Also Configuring Camel Component Endpoint Getting Started Change Notification Preferences View Online | View Changes | Add Comment
[CONF] Apache Camel > Solr
Solr Page added by Ben O'Day Solr Component Available as of Camel 2.9 The Solr component allows interfacing with an Apache Lucene Solr server. Maven users will need to add the following dependency to their pom.xml for this component: org.apache.camel camel-solr x.x.x URI format solr://host[:port]?[options] operations todo example todo See Also Configuring Camel Component Endpoint Getting Started Change Notification Preferences View Online | Add Comment