此内容没有您所选择的语言版本。
Chapter 89. Lucene
Lucene (Indexer and Search) Component 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Available as of Apache Camel 2.2
The lucene component is based on the Apache Lucene project. Apache Lucene is a powerful high-performance, full-featured text search engine library written entirely in Java. For more details about Lucene, please see the following links:
The lucene component in camel facilitates integration and utilization of Lucene endpoints in enterprise integration patterns and scenarios. The lucene component does the following
- builds a searchable index of documents when payloads are sent to the Lucene Endpoint
- facilitates performing of indexed searches in Apache Camel
This component only supports producer endpoints.
URI format 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
lucene:searcherName:insert[?options] lucene:searcherName:query[?options]
lucene:searcherName:insert[?options]
lucene:searcherName:query[?options]
You can append query options to the URI in the following format,
?option=value&option=value&...
Insert Options 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
| Name | Default Value | Description |
|---|---|---|
analyzer
|
StandardAnalyzer
|
An Analyzer builds TokenStreams, which analyze text. It thus represents a policy for extracting index terms from text. The value for analyzer can be any class that extends the abstract class org.apache.lucene.analysis.Analyzer. Lucene also offers a rich set of analyzers out of the box |
indexDir
|
./indexDirectory
|
A file system directory in which index files are created upon analysis of the document by the specified analyzer |
srcDir
|
null
|
An optional directory containing files to be used to be analyzed and added to the index at producer startup. |
Query Options 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
| Name | Default Value | Description |
|---|---|---|
analyzer
|
StandardAnalyzer
|
An Analyzer builds TokenStreams, which analyze text. It thus represents a policy for extracting index terms from text. The value for analyzer can be any class that extends the abstract class org.apache.lucene.analysis.Analyzer. Lucene also offers a rich set of analyzers out of the box |
indexDir
|
./indexDirectory
|
A file system directory in which index files are created upon analysis of the document by the specified analyzer |
maxHits
|
10
|
An integer value that limits the result set of the search operation |
Message Headers 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
| Header | Description |
|---|---|
QUERY
|
The Lucene Query to performed on the index. The query may include wildcards and phrases. |
RETURN_LUCENE_DOCS
|
Camel 2.15: Set this header to true to include the actual Lucene documentation when returning hit information. |
Lucene Producers 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
This component supports 2 producer endpoints.
- insert - The insert producer builds a searchable index by analyzing the body in incoming exchanges and associating it with a token ("content").
- query - The query producer performs searches on a pre-created index. The query uses the searchable index to perform score & relevance based searches. Queries are sent via the incoming exchange contains a header property name called 'QUERY'. The value of the header property 'QUERY' is a Lucene Query. For more details on how to create Lucene Queries check out http://lucene.apache.org/java/3_0_0/queryparsersyntax.html
Lucene Processor 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
There is a processor called LuceneQueryProcessor available to perform queries against lucene without the need to create a producer.
Example 1: Creating a Lucene index 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Example 2: Performing searches using a Query Producer 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Example 3: Performing searches using a Query Processor 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!