solr 本地搭建
2024-08-29 19:43:38
1. 运行
D:\solr-4.7.2\example
--> java -jar start.jar
2. 添加插件IK
D:\solr-4.7.2\example\solr-webapp\webapp\WEB-INF\classes
-->IKAnalyzer.cfg.xml
-->stopword.dic
D:\solr-4.7.2\example\solr-webapp\webapp\WEB-INF\lib
-->IKAnalyzer2012FF_u1.jar
一定要用这个版本的,兼容 solr 4.7.2
3.schema.xml 使用IK进行索引和分词查询
--> <fieldType name="text_ik" class="solr.TextField">
--> <analyzer type="index" isMaxWordLength="false"
--> class="org.wltea.analyzer.lucene.IKAnalyzer"/>
--> <analyzer type="query" isMaxWordLength="true"
--> class="org.wltea.analyzer.lucene.IKAnalyzer"/>
--> </fieldType>
4. mysql 数据库进行分词索引
solrconfig.xml 添加数据库导入缓存或更新缓存
--> <requestHandler name="/dataimport" --> class="org.apache.solr.handler.dataimport.DataImportHandler">
--> <lst name="defaults">
--> <str name="config">data-config.xml</str>
--> </lst>
--> </requestHandler>
5.需要的jar包
D:\solr-4.7.2\example\solr-webapp\webapp\WEB-INF\lib
mysql-connector-java-5.1.25.jar
solr-dataimporthandler-4.7.2.jar
solr-dataimporthandler-extras-4.7.2.jar
6.data-config.xml
<dataConfig>
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.10.15:3306/wenda" user="root" password="root@sg"/>
<document name="wendaQuestion">
<entity pk="id" name="question" query="select * from wenda_question where delete_flag != 1"
deltaQuery="select id from wenda_question where updated_at > '${dataimporter.last_index_time}'"
deletedPkQuery="select id from wenda_question where delete_flag = 1"
deltaImportQuery="select * from wenda_question where ID='${dataimporter.delta.ID}'"
>
<field column="id" name="id" />
<field column="title" name="title" />
<field column="answer_count" name="answerCount" />
<field column="default_category_id" name="categoryId" />
<entity name="categoryids" query="SELECT GROUP_CONCAT(catagory_id) as categoryids FROM wenda_question_category_ref t WHERE question_id ='${question.id}'" />
<entity name="acceptCount" query="SELECT COUNT(1) AS acceptCount FROM wenda_answer WHERE accept_flag = 1 AND question_id ='${question.id}'" />
</entity>
</document>
</dataConfig>
7.schema.xml 字段映射
<field name="id" type="long" indexed="true" stored="true" required="true" />
<field name="title" type="text_ik" indexed="true" stored="true" />
<field name="answerCount" type="long" indexed="true" stored="true" />
<field name="categoryId" type="long" indexed="true" stored="true" />
<field name="categoryids" type="string" indexed="true" stored="true" />
<field name="acceptCount" type="long" indexed="true" stored="true" required="true" />
8.elevate.xml id 为long 出错修复 MA147LL/A 换成 1 IW-02 换成 2
<query text="ipod">
<doc id="1" /> <!-- "MA147LL/A" put the actual ipod at the top -->
<doc id="2" exclude="true" /> <!-- "IW-02"exclude this cable -->
</query>
最新文章
- json序列化及反序列化
- Full exploitation of a cluster hardware configuration requires some enhancements to a single-system operating system.
- 使用Navicat修改SQLite数据库提示:no such collation sequence: LOCALIZED
- C#.NET 大型通用信息化系统集成快速开发平台 4.0 版本 - 省市区数据权限的实现效果
- (HBase) Error: JAVA_HOME is not set and Java could not be found
- Spring 整合 Struts2
- Android View 如何绘制
- AppleScript
- BG雪碧图制作要求
- ZOJ 1115 Digital Roots(简单,字符串与数)
- python 字典items和iteritems
- struts2框架的第一个程序
- Ext学习-高级组件介绍
- 微信小程序添加、删除class’
- 【BZOJ5020】【THUWC2017】在美妙的数学王国中畅游(Link-Cut Tree,组合数学)
- A The Empire Age
- Python&#160;对服务器返回数据编码进行判断之chardet
- SpringBoot Controller 中 HttpServletRequest ServletInputStream 读取不到数据该怎么处理
- Mysql模糊查询like效率,以及更高效的写法
- ubuntu16.04下idea、webstorm等开发工具不能输入中文问题
热门文章
- Json模块(dumps、loads、dump、load)函数篇
- centos7编译安装LNMP(nginx-1.16.0,mysql8.0.16,php-7.3.6)常见问题报错及解决方法
- RocketMQ事务消息学习及刨坑过程
- Qt+VC2010+glew环境安装配置
- Python中的可变对象与不可变对象、浅拷贝与深拷贝
- jar包的多层级maven依赖的坑与正确传递方法
- Redis实战篇
- 03jmeter-json提取器
- 了解这一行的,腰包都鼓鼓的了,程序辅导,CS作业
- 拨云见日,彻底弄清楚Java日志框架 log4j, logback, slf4j的区别与联系