欢迎投稿

今日深度:

solr详解,

solr详解,


一.什么是solr?

solr是基于lucene的全文搜索引擎。提供了比lucene更多的查询语言,同时实现了可配置,可扩展,索引性能优化。提供了较为完备的引擎解决方案。

二.solr和lucene的区别?

1.lucene是全文搜索引擎工具包,不是一个完整的全文检索引擎,lucenen提供了完整的查询引擎和索引引擎,目的是为开发人员提供简单易用的开发工具包
2.solr是搜索引擎系统,可以独立运行,通过solr可以快速的构建企业的搜索引擎。

三.solr目录结构

(1)bin:是脚本的启动目录

(2)contrib:第三方包存放的目录

(4)dist:编译打包后存放目录,即构建后的输出产物存放的目录

(5)docs:solr文档的存放目录

(6)example:示范例子的存放目录,这里展示了DIH,即数据导入处理的例子

三.solr的安装和相关配置

安装

1.创建solr文件夹

mkdir /usr/local/solor

2.将tomcat和solr的压缩包拷贝到该目录下并解压

tar -zxf solr-4.10.3.tgz.tgz 
tar -zxf apache-tomcat-7.0.47

3.solr服务部署到tomcat下
将/usr/local/solr/solr-4.10.3/dist下的solr-4.10.3.war部署到tomcat下(建议改名为solr.war)

cd /usr/local/solr/solr-4.10.3/dist
cp solr-4.10.3.war /usr/local/solr/apache-tomcat-7.0.47/webapps/solr.war

4.启动tomcat将war包解压。(再关闭后删除war包。。切记)

cd /usr/local/solr/apache-tomcat-7.0.47/bin
./startup.sh 

5.复制jar包solr工程中

cd /usr/local/solr/solr-4.10.3/example/lib/ext

cp * /usr/local/solr/apache-tomcat-7.0.47/webapps/solr/WEB-INF/lib

6.创建solrhome,存放solr服务器所有配置文件的目录

cd /usr/local/solr/solr-4.10.3/example
cp -r solr /usr/local/solr/solrhome

7.配置solrhome

cd /usr/local/solr/apache-tomcat-7.0.47/webapps/solr/WEB-INF
vim web.xml

修改:
    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/usr/local/solr/solrhome</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

8.重启tomcat
访问 xxx.xx.x.x:8080/solr

配置中文分析器及业务字段

(中文分析其部分)

1.把分析其的jar包添加到solr工程中

2.需要把IKAnalyzer需要的扩展词典及停用词词典、配置文件复制到solr工程的classpath。
(WEB-INF下创建classes目录 --拷贝 ext_stopword.dic IKAnalyzer.cfg.xml mydict.dic)

3.配置filedType(/usr/local/solr/solrhome/collection1/conf/schema.xml)

<fieldType name="text_ik" class="solr.TextField">
  <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>
</fieldType>
(业务字段部分)

同样是上面的配置文件末尾

<field name="item_title" type="text_ik" indexed="true" stored="true"/>
<field name="item_sell_point" type="text_ik" indexed="true" stored="true"/>
<field name="item_price"  type="long" indexed="true" stored="true"/>
<field name="item_image" type="string" indexed="false" stored="true" />
<field name="item_category_name" type="string" indexed="true" stored="true" />
<field name="item_desc" type="text_ik" indexed="true" stored="false" />

<field name="item_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/>
<copyField source="item_title" dest="item_keywords"/>
<copyField source="item_sell_point" dest="item_keywords"/>
<copyField source="item_category_name" dest="item_keywords"/>
<copyField source="item_desc" dest="item_keywords"/>

4.重启

www.htsjk.Com true http://www.htsjk.com/solr/38980.html NewsArticle solr详解, 一.什么是solr? solr是基于lucene的全文搜索引擎。提供了比lucene更多的查询语言,同时实现了可配置,可扩展,索引性能优化。提供了较为完备的引擎解决方案。 二.solr和lucen...
相关文章
    暂无相关文章
评论暂时关闭