solr

solr 实现去掉重复的搜索结果,打SOLR-236_collapsing.patch补丁(2)

第一步骤:

ant patch,把下面的内容保存为 patch-build.xml 放到 D:\apache-solr-1.3.0 目录下:

<?xml version="1.0" encoding="UTF-8"?> 
<project name="solr-patch" default="apply-patch" basedir=".">   
 
    <target name="apply-patch" description="Apply a patch file.  Set -Dpatch.file"> 
        <patch patchfile="${patch.file}" strip="0"/> 
    </target> 
</project> 

第二步骤:

ant 打补丁:

D:\apache-solr-1.3.0>ant -Dpatch.file=SOLR-236_collapsing.patch -f patch-build.xml
Buildfile: patch-build.xml

apply-patch:
[patch] patching file src/test/org/apache/solr/search/TestDocSet.java
[patch] patching file src/java/org/apache/solr/search/CollapseFilter.java
[patch] patching file src/java/org/apache/solr/search/DocSet.java
[patch] patching file src/java/org/apache/solr/search/NegatedDocSet.java
[patch] patching file src/java/org/apache/solr/search/SolrIndexSearcher.java
[patch] patching file src/java/org/apache/solr/common/params/CollapseParams.java
[patch] patching file src/java/org/apache/solr/handler/component/CollapseComponent.java

BUILD SUCCESSFUL
Total time: 0 seconds

第三步骤:

源码打上了补丁,然后用 ant 构建源码:

D:\apache-solr-1.3.0>ant dist

在 D:/apache-solr-1.3.0/dist 目录下可以找到编译好的 solr 了。然后把 solr 放到 tomcat 中去运行它,把下面的内容保存在 TOMCAT_HOME/conf/Catalina/localhost/solr.xml 文件中:

<Context docBase="D:\apache-solr-1.3.0\dist\apache-solr-1.3.0.war" reloadable="true" > 
    <Environment name="solr/home" type="java.lang.String" value="D:\apache-solr-1.3.0\example\solr" override="true" /> 
</Context> 
修改 D:\apache-solr-1.3.0\example\solr\conf\solrconfig.xml 使 solr 可以支持 collapse。

定义搜索组件,在 QueryComponent 附近:

<searchComponent name="collapse" class="org.apache.solr.handler.component.CollapseComponent" /> 
定义一个 handler 使用上面的搜索组件:

<requestHandler name="collapse" class="solr.SearchHandler"> 
  <!-- default values for query parameters --> 
   <lst name="defaults"> 
     <str name="echoParams">explicit</str> 
   </lst> 
  <arr name="components"> 
    <str>collapse</str> 
    <str>debug</str> 
  </arr> 
</requestHandler> 



http://blog.chenlb.com/2009/04/apply-solr-collapsing-patch-remove-duplicate-result.html

你可能感兴趣的:(Solr)