如何在compass-lucene搜索中使用分析器

时间:2010-09-20 13:07:42

标签: search lucene indexing compass-lucene

如何在罗盘中索引和搜索数据时添加罗盘分析器。我正在使用基于模式的罗盘配置。我想使用没有停用词的StandardAnalyzer。因为我想按原样索引数据,而不是忽略像这样的搜索词AND,OR,IN。默认分析器将忽略我为索引编制的数据中的AND,OR,IN。

如何通过代码或通过xml配置雪球分析器。如果有人可以给我发一个例子。

1 个答案:

答案 0 :(得分:0)

以下是示例。您还可以找到更多详细信息here

<comp:searchEngine useCompoundFile="false" cacheInvalidationInterval="-1">
        <comp:allProperty enable="false" />
        <!--
            By Default, compass uses StandardAnalyzer for indexing and searching. StandardAnalyzer
            will use certain stop words (stop words are not indexed and hence not searcheable) which are
            valid search terms in the DataSource World. For e.g. 'in' for Indiana state, 'or' for Oregon etc.
            So we need to provide our own Analyzer.
        -->
        <comp:analyzer name="default" type="CustomAnalyzer"
            analyzerClass="com.ICStandardAnalyzer" />
        <comp:analyzer name="search" type="CustomAnalyzer"
            analyzerClass="com.ICStandardAnalyzer" />
        <!--
            Disable the optimizer as we will optimize the index as a separate batch job

            Also, the merge factor is set to 1000, so that merging doesnt happen during the commit time.
            Merging is a time consuming process and will be done by the batched optimizer
        -->
        <comp:optimizer schedule="false" mergeFactor="1000"/>
    </comp:searchEngine>