xiu12 发表于 2015-7-17 07:22:12

Apache SOLR and Carrot2集成

1.环境
  下载软件

  名称
  地址
  solr-integration-strategies-gh-pages.zip
  https://github.com/carrot2/solr-integration-strategies
  solr-4.7.1
   apache-tomcat-6.0.39
   carrot2-webapp-3.9.2.war
   
2.启动Solr
  使用Jetty启动solr

  F:\solr\solr-4.7.1\example>java -Dsolr.solr.home=../../carrot2-3.8.0-4.7.1/solr-home -jar start.jar
  
  访问http://localhost:8983/solr/#/

  
3.导入数据
  使用solr-docs中post.jar向solr中导入数据

  F:\solr\solr-integration-strategies-gh-pages\solr-docs>java -jar post.jar 20newsgroups
  

  
4.聚类集成到Solr中

  
  carrot2提供的solrconfig.xml中的对搜索结果进行了配置

  
  
  

  
  
     
        default
        org.carrot2.clustering.lingo.LingoClusteringAlgorithm
        20
        clustering/carrot2
        ENGLISH
     
  
  
  配置
  config1_1(search handler):

  
     
        edismax
        title^1.5 content^1.0
        100
  *,score
  
        
        true            
        true   
        default   
  
        
        name            
        title         
        content      
     
  
     
     
        clustering
     
  
  
  config1_2 (search handler returning a subset of fields)

  
     
        edismax
        title^1.5 content^1.0
        100
  
        
  name,title,score
  
        true
        true
        default
  
        name
        title
        content
     
  
     
        clustering
     
  
  
  config1_3(search handler returning contextual snippets)

  
     
        edismax
        title^1.5 content^1.0
        100
  
        name,title,score
  
        
        true
        content
        
        
        
        3
        200
  
        true
        true
        default
  
        name
        title
        content
     
  
     
        clustering
     
  
  
  config2_1(search handler clustering query-in-context snippets)

  
     
        edismax
        title^1.5 content^1.0
        100
  
        name,title,score
  
        true
        true
        default
  
        name
        title
        content
  
        
        true
        
        3
     
  
     
        clustering
     
  
  
  访问
  http://localhost:8983/solr/example/config1_1?q=memory&wt=xml&indent=true

  
5.集成solr到carrot2的网站

  准备Tomcat和carrot2-webapp-3.9.2
  将carrot2-webapp-3.9.2.war解压,修改F:\solr\apache-tomcat-6.0.39\webapps\carrot2-webapp-3.9.2\WEB-INF\suites中suite-webapp.xml文件

  
  
  
        Solr
        Solr Search Engine
        icons/solr.png
        s
        Solr document source queries an instance of Apache Solr search engine.
        
        test
        solr
        
     
  
  
  
  
  
  修改source-solr-attributes.xml文件

  
  
     
        overridden-attributes
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
     
  
  
  
6.启动Tomcat
  将carrot2-webapp-3.9.2放到tomcat的webapps下并启动tomcat

  
  访问地址http://localhost:8080/carrot2-webapp-3.9.2

  
  搜索memory

  
  Carrot2的图形界面

  
页: [1]
查看完整版本: Apache SOLR and Carrot2集成