Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added operations table and examples

...

The Solr component allows interfacing you to interface with an Apache Lucene Solr server.

...

Code Block
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.

Code Block
java
java

      from("direct:start")
          .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT))
          .setHeader(SolrConstants.FIELD + "id", body())
          .to("solr://localhost:8983/solr");
    </route>
Code Block
xml
xml

    <route>
      <from uri="direct:start"/>
        <setHeader headerName="SolrOperation">
            <constant>INSERT</constant>
        </setHeader>
        <setHeader headerName="SolrField.id">
            <simple>${body}</simple>
        </setHeader>
        <to uri="solr://localhost:8983/solr"/>
    </route>

A client would simply need to pass a String body message to this route as follows.

Code Block
java
java

    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

todo

example

todo

Include Page
CAMEL:Endpoint See Also
CAMEL:Endpoint See Also