solr环境搭建
来源:互联网 发布:cae有限元分析软件 编辑:程序博客网 时间:2024/06/06 07:27
solr 是什么我就不多说了,网上有一大堆就不献丑。借助网上的教程,将此记录下来。
下载地址:http://archive.apache.org/dist/lucene/solr/
下好相应版本
解压目录如下
Bin:solr的脚本
Contrib:solr为了增强自身的功能,所添加的扩展依赖包
Dist:solr build过程时产生的war包和jar包,还有它的一些依赖包
Docs:文档
Example:例子目录
Solr:配置了solr运行时的信息,它是一个标准的solrhome目录
Multicore:可以配置多个SolrCore实例
Webapps:solr.war的目录
Licenes:版本信息
Solrhome是一个目录,它是solr运行的主目录,它包括多个SolrCore目录,SolrCore目录中就solr实例的运行配置文件和数据文件。
Solrhome中可以包括多个SolrCore,每个SolrCore互相独立,而且可以单独对外提供搜索和索引服务。
复制example\solr目录里的文件复制到一个路径配置solrhome
Solrhome的目录:
SolrCore目录:
拷贝example\webapps 里面的war放入tomcat或其他容器 若项目报错看查看是否缺少相应jar (example\lib\ext目录下)
找到找到web.xml
打开注释配置solrhome
重启服务输入管理url http://localhost:8080/solr/
则启动成功
一个solr工程中可以配置多个SolrCore实例。可直接复制solrhome下的collection1到本目录下,并且改名为collection2 修改collection2文件中core.properties 【name】
solr配置ik分词
1、把IKAnalyzer2012FF_u1.jar添加到solr/WEB-INF/lib目录下
2、复制IKAnalyzer的配置文件和自定义词典和停用词词典到solr的classpath下。【ext.dic IKAnalyzer.cfg.xml stopword.dic 】注意文本必须是utf-8不然分词无效
3、配置fieldType,指定使用中文分词器
SolrCore config/schema.xml文件
<fieldType name="text_ik" class="solr.TextField"> <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType>
field type 指定ik分词即可
<field name="product_name" type="text_ik" indexed="true" stored="true" multiValued="false" />
如何配置solr 将数据库数据生成索引数据?
SolrCore config/schema.xml文件
<field name="product_name" type="text_ik" indexed="true" stored="true" multiValued="false" /> <field name="product_catalog" type="string" indexed="true" stored="true" multiValued="false" /> <field name="product_catalog_name" type="string" indexed="true" stored="true" multiValued="false" /> <field name="product_price" type="float" indexed="true" stored="true" multiValued="false" /> <field name="product_description" type="text_ik" indexed="true" stored="false" /> <field name="product_pic" type="string" indexed="false" stored="true" /> <field name="product_keywords" type="text_ik" indexed="true" stored="false" multiValued="true" /> <copyField source="product_name" dest="product_keywords"/> <copyField source="product_description" dest="product_keywords"/>
SolrCore config/solrconfig.xml文件
导入相应jar注意路径
<lib dir="${solr.install.dir:..}/contrib/extraction/lib" regex=".*\.jar" /> <lib dir="${solr.install.dir:..}/dist/" regex="solr-cell-\d.*\.jar" /> <lib dir="${solr.install.dir:..}/contrib/clustering/lib/" regex=".*\.jar" /> <lib dir="${solr.install.dir:..}/dist/" regex="solr-clustering-\d.*\.jar" /> <lib dir="${solr.install.dir:..}/contrib/langid/lib/" regex=".*\.jar" /> <lib dir="${solr.install.dir:..}/dist/" regex="solr-langid-\d.*\.jar" /> <lib dir="${solr.install.dir:..}/contrib/velocity/lib" regex=".*\.jar" /> <lib dir="${solr.install.dir:..}/dist/" regex="solr-velocity-\d.*\.jar" /> <lib dir="${solr.install.dir:..}/dist/" regex="solr-dataimporthandler-.*\.jar" /> <lib dir="${solr.install.dir:..}/dist/" regex="mysql-connector-java-.*\.jar" />
增加节点配置
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">solr-data-config.xml</str> </lst> </requestHandler>
solr-data-config.xml
name 对应SolrCore config/schema.xml文件 field name
<dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/xyw_manager" user="root" password="xuyw" /> <document> <entity name="item" query="select pid,name,catalog,catalog_name,price,description,picture from products"> <field column="pid" name="id" /> <field column="name" name="product_name" /> <field column="catalog" name="product_catalog" /> <field column="catalog_name" name="product_catalog_name" /> <field column="price" name="product_price" /> <field column="description" name="product_description" /> <field column="picture" name="product_pic" /> </entity> </document></dataConfig>
重启执行管理界面 dataimport 数据将导入
- solr的环境搭建
- Solr 5.2 环境搭建
- solr集群环境搭建
- [solr] - 环境搭建
- [solr] - 环境搭建2
- [solr] - 环境搭建
- [solr] - 环境搭建2
- solr环境搭建
- Solr环境搭建
- [solr] - 环境搭建
- solr入门-环境搭建
- solr 环境搭建
- Solr 6.0环境搭建
- Solr环境搭建
- 搭建solr环境
- Solr学习02:搭建Solr环境
- Solr(1)环境搭建
- solr + eclipse 调试环境搭建
- Poj 1177 Picture
- 变量
- ThreadLocal管理下的Session
- BZOJ4456: [Zjoi2016]旅行者
- 删除所有文章,重新开始
- solr环境搭建
- winform 控件命名规范
- HDU 2841 Visible Trees (容斥原理+素因子分解)
- 多线程经典面试题
- 印度
- Announcing the 2016 Android Experiments I/O Challenge!
- CF 431 C k-Tree(有序完全背包)
- objective-c inherit
- 界面根据权限显示