camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Solr
Date Fri, 02 Dec 2011 07:36:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Solr">Solr</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~boday">Ben
O&#39;Day</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        added operations table and examples<br />
    </div>
        <br/>
                         <h4>Changes (10)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >*Available as of Camel 2.9* <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" >The Solr component allows <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">interfacing</span>
<span class="diff-added-words"style="background-color: #dfd;">you to interface</span>
with an Apache Lucene Solr server. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>Maven users will need to
add the following dependency to their {{pom.xml}} for this component: <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">solr://host[:port]<span
class="diff-added-chars"style="background-color: #dfd;">/solr</span>?[options]</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >h3. <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">o</span><span
class="diff-added-chars"style="background-color: #dfd;">O</span>perations</span>
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">[todo]
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
following operations are currently supported. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3.
example <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">||operation
||description| <br>|INSERT|insert a new record based on headers values (headers must
be prefixed with &quot;SolrField.&quot;)| <br>|ADD_BEAN|insert a new record
based on values in an [annotated bean|http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr]|
<br>|DELETE_BY_ID|delete a record by ID| <br>|DELETE_BY_QUERY|delete a record
by a query| <br>|COMMIT|performs a commit on any pending index changes| <br>|ROLLBACK|performs
a rollback on any pending index changes| <br>|OPTIMIZE|performs a commit on any pending
index changes and then runs the optimize command| <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">[todo]
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
Example <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Below
is a simple INSERT example in Java and Spring XML. <br> <br>{code:java} <br>
     from(&quot;direct:start&quot;) <br>          .setHeader(SolrConstants.OPERATION,
constant(SolrConstants.OPERATION_INSERT)) <br>          .setHeader(SolrConstants.FIELD
+ &quot;id&quot;, body()) <br>          .to(&quot;solr://localhost:8983/solr&quot;);
<br>    &lt;/route&gt; <br>{code} <br> <br>{code:xml} <br>
   &lt;route&gt; <br>      &lt;from uri=&quot;direct:start&quot;/&gt;
<br>        &lt;setHeader headerName=&quot;SolrOperation&quot;&gt; <br>
           &lt;constant&gt;INSERT&lt;/constant&gt; <br>        &lt;/setHeader&gt;
<br>        &lt;setHeader headerName=&quot;SolrField.id&quot;&gt; <br>
           &lt;simple&gt;${body}&lt;/simple&gt; <br>        &lt;/setHeader&gt;
<br>        &lt;to uri=&quot;solr://localhost:8983/solr&quot;/&gt; <br>
   &lt;/route&gt; <br>{code} <br> <br>A client would simply need
to pass a String body message to this route as follows. <br> <br>{code:java} <br>
   template.sendBody(&quot;direct:start&quot;, &quot;value1&quot;); <br>{code}
<br> <br>h3. Querying Solr <br> <br>Currently, this component doesn&#39;t
support querying data (will be added later).  For now, you can query Solr in a route using
[HTTP].   <br> <br>TODO: add a simple example to retrieve the data inserted above.
  <br> <br>For more information, see these resources... <br> <br>[Solr
Query Tutorial|http://lucene.apache.org/solr/tutorial.html#Querying+Data] <br> <br>[Solr
Query Syntax|http://wiki.apache.org/solr/SolrQuerySyntax] <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{include:Endpoint See Also} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Solr-SolrComponent"></a>Solr Component</h2>
<p><b>Available as of Camel 2.9</b></p>

<p>The Solr component allows you to interface with an Apache Lucene Solr server.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-solr<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="Solr-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
solr:<span class="code-comment">//host[:port]/solr?[options]</span>
</pre>
</div></div>

<h3><a name="Solr-Operations"></a>Operations</h3>

<p>The following operations are currently supported.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>operation </th>
<th class='confluenceTh'>description</th>
</tr>
<tr>
<td class='confluenceTd'>INSERT</td>
<td class='confluenceTd'>insert a new record based on headers values (headers must be
prefixed with "SolrField.")</td>
</tr>
<tr>
<td class='confluenceTd'>ADD_BEAN</td>
<td class='confluenceTd'>insert a new record based on values in an <a href="http://wiki.apache.org/solr/Solrj#Directly_adding_POJOs_to_Solr"
class="external-link" rel="nofollow">annotated bean</a></td>
</tr>
<tr>
<td class='confluenceTd'>DELETE_BY_ID</td>
<td class='confluenceTd'>delete a record by ID</td>
</tr>
<tr>
<td class='confluenceTd'>DELETE_BY_QUERY</td>
<td class='confluenceTd'>delete a record by a query</td>
</tr>
<tr>
<td class='confluenceTd'>COMMIT</td>
<td class='confluenceTd'>performs a commit on any pending index changes</td>
</tr>
<tr>
<td class='confluenceTd'>ROLLBACK</td>
<td class='confluenceTd'>performs a rollback on any pending index changes</td>
</tr>
<tr>
<td class='confluenceTd'>OPTIMIZE</td>
<td class='confluenceTd'>performs a commit on any pending index changes and then runs
the optimize command</td>
</tr>
</tbody></table>
</div>


<h3><a name="Solr-Example"></a>Example</h3>

<p>Below is a simple INSERT example in Java and Spring XML.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
      from(<span class="code-quote">"direct:start"</span>)
          .setHeader(SolrConstants.OPERATION, constant(SolrConstants.OPERATION_INSERT))
          .setHeader(SolrConstants.FIELD + <span class="code-quote">"id"</span>,
body())
          .to(<span class="code-quote">"solr:<span class="code-comment">//localhost:8983/solr"</span>);
</span>    &lt;/route&gt;
</pre>
</div></div>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
    <span class="code-tag">&lt;route&gt;</span>
      <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
        <span class="code-tag">&lt;setHeader headerName=<span class="code-quote">"SolrOperation"</span>&gt;</span>
            <span class="code-tag">&lt;constant&gt;</span>INSERT<span
class="code-tag">&lt;/constant&gt;</span>
        <span class="code-tag">&lt;/setHeader&gt;</span>
        <span class="code-tag">&lt;setHeader headerName=<span class="code-quote">"SolrField.id"</span>&gt;</span>
            <span class="code-tag">&lt;simple&gt;</span>${body}<span
class="code-tag">&lt;/simple&gt;</span>
        <span class="code-tag">&lt;/setHeader&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"solr://localhost:8983/solr"</span>/&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
</pre>
</div></div>

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    template.sendBody(<span class="code-quote">"direct:start"</span>, <span
class="code-quote">"value1"</span>);
</pre>
</div></div>

<h3><a name="Solr-QueryingSolr"></a>Querying Solr</h3>

<p>Currently, this component doesn't support querying data (will be added later).  For
now, you can query Solr in a route using <a href="/confluence/display/CAMEL/HTTP" title="HTTP">HTTP</a>.
 </p>

<p>TODO: add a simple example to retrieve the data inserted above.  </p>

<p>For more information, see these resources...</p>

<p><a href="http://lucene.apache.org/solr/tutorial.html#Querying+Data" class="external-link"
rel="nofollow">Solr Query Tutorial</a></p>

<p><a href="http://wiki.apache.org/solr/SolrQuerySyntax" class="external-link" rel="nofollow">Solr
Query Syntax</a></p>

<h3><a name="Solr-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Solr">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27832560&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Solr?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message