准备solr搭建搜索的学习笔记

本文详细介绍Solr的安装步骤及配置过程,包括Tomcat环境下部署Solr、添加用户验证、实现中文分词功能等内容。

一,安装部署solr

1. 下载tomcat解压,这里选择的是tomcat8

2. 下载solr最新版本(4.10.1)并解压solr文件夹下,下载地址是http://lucene.apache.org/solr/。 并将解压后solr\example\solr中的内容拷贝至的solrHome\下

3. 将solr解压后的solr\dist\solr-4.10.1.war 拷贝至apache-tomcat-8.0.12\webapps目录,并重命名为solr.war。

4. 在apache-tomcat-8.0.12\conf\server.xml中配置solr的Context,顺便修改端口号8080为80

1
2
3
< Context  path = "/solr"  docBase = "solr"  reloadable = "false"  crossContext = "true" >
    < Environment  name = "solr/home"  type = "java.lang.String"  value = "D:\workspace\develop\study\sorl_test\solrHome" />
</ Context >

5. 启动tomcat,并访问solr:http://localhost/solr,页面显示404,并在localhost日志中可以看到错误信息

1
2
3
4
5
6
7
8
SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter SolrRequestFilter 
java.lang.NoClassDefFoundError: Failed to initialize Apache Solr: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging 
at org.apache.solr.servlet.CheckLoggingConfiguration.check(CheckLoggingConfiguration.java:28) 
at org.apache.solr.servlet.BaseSolrFilter.<clinit>(BaseSolrFilter.java:31) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

6. 将solr\example\lib\ext下的jar文件件,拷贝至apache-tomcat-8.0.12\webapps\solr\WEB-INF\lib下

7. 重新启动,并访问solr

测试分词效果



二,为solr增加用户验证

1. 在tomcat的apache-tomcat-8.0.12\conf\tomcat-users.xml 添加用户角色并指定访问的用户名密码

1
2
< role  rolename = "solr" />
< user  username = "solr"  password = "52menshao"  roles = "solr" />

2. 在apache-tomcat-8.0.12\webapps\solr\WEB-INF\web.xml中添加用户访问权限设置 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
< security-constraint >
       < web-resource-collection >
           < web-resource-name >Solr Lockdown</ web-resource-name >
           < url-pattern >/</ url-pattern >
           < http-method >GET</ http-method >
           < http-method >POST</ http-method >
       </ web-resource-collection >
       < auth-constraint >
           < description >This applies only to the "tomcat" security role</ description >
           < role-name >solr</ role-name >
           < role-name >admin</ role-name >
       </ auth-constraint >
       < user-data-constraint >
           < transport-guarantee >NONE</ transport-guarantee >
       </ user-data-constraint >
   </ security-constraint >
  
   < login-config >
       < auth-method >BASIC</ auth-method >
       < realm-name >Solr</ realm-name >
   </ login-config >


三、为solr添加中文分词

 1. 在不做任何改动的情况下,做中文分词如下


2. 此次为solr进行中文分词,选择的组件是mmseg4j,开源地址是:https://github.com/chenlb/mmseg4j-solr

     mmseg4j支持最多分词,是一款很优秀的中文分词器,是用Chih-Hao Tsai 的 MMSeg 算法( http://technology.chtsai.org/mmseg/ )实现的中文分词器,并实现 lucene 的analyzer 和 solr 的TokenizerFactory 以方便在Lucene和Solr中使用。 

3. 下载中文分词需要依赖的jar包,放于apache-tomcat-8.0.12\webapps\solr\WEB-INF\lib下

      1. mmseg4j-for-solr(mmseg4j-solr-2.2.0.jar)           2. mmseg4j-core(mmseg4j-core-1.10.0.jar)

4.  修改solr_home\collection1\conf\schema.xml,

     4.1 添加如下代码,代码片段可以从https://github.com/chenlb/mmseg4j-solr中直接拷贝,可修改dicPath 参数 - 设置自定义的扩展词库,支持相对路径(相对于 solr_home).


     4.2 更改原有配置,使原有一些重要的字段从英文分词器换成中文分词器,使之支持中文分词


5. 重启tomcat查看效果

四、 Solr后台的使用

     略,这里可以自己先了解一下,功能一目了然

五、SorlJ的使用

 添加solrj的jar文件

1
2
3
4
5
< dependency >
     < groupId >org.apache.solr</ groupId >
     < artifactId >solr-solrj</ artifactId >
     < version >4.10.1</ version >
   </ dependency >



内容概要:本文系统阐述了企业新闻发稿在生成式引擎优化(GEO)时代下的全渠道策略与效果评估体系,涵盖当前企业传播面临的预算、资源、内容与效果评估四大挑战,并深入分析2025年新闻发稿行业五大趋势,包括AI驱动的智能化转型、精准化传播、首发内容价值提升、内容资产化及数据可视化。文章重点解析央媒、地方官媒、综合门户和自媒体四类媒体资源的特性、传播优势与发稿策略,提出基于内容适配性、时间节奏、话题设计的策略制定方法,并构建涵盖品牌价值、销售转化与GEO优化的多维评估框架。此外,结合“传声港”工具实操指南,提供AI智能投放、效果监测、自媒体管理与舆情应对的全流程解决方案,并针对科技、消费、B2B、区域品牌四大行业推出定制化发稿方案。; 适合人群:企业市场/公关负责人、品牌传播管理者、数字营销从业者及中小企业决策者,具备一定媒体传播经验并希望提升发稿效率与ROI的专业人士。; 使用场景及目标:①制定科学的新闻发稿策略,实现从“流量思维”向“价值思维”转型;②构建央媒定调、门户扩散、自媒体互动的立体化传播矩阵;③利用AI工具实现精准投放与GEO优化,提升品牌在AI搜索中的权威性与可见性;④通过数据驱动评估体系量化品牌影响力与销售转化效果。; 阅读建议:建议结合文中提供的实操清单、案例分析与工具指南进行系统学习,重点关注媒体适配性策略与GEO评估指标,在实际发稿中分阶段试点“AI+全渠道”组合策略,并定期复盘优化,以实现品牌传播的长期复利效应。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值