solr5.5 基于内置jetty配置 Ubuntu

来源:互联网 发布:dnf赌马知乎 编辑:程序博客网 时间:2024/06/01 17:15

下载地址:http://archive.apache.org/dist/lucene/solr/


在你的目录下直接解压  tar -zxvf xxxxxx.tgz

解压之后进入

root@ubuntu:/usr/local/zx/solr/solr# pwd/usr/local/zx/solr/solrroot@ubuntu:/usr/local/zx/solr/solr# lltotal 1232drwxr-xr-x  9 root root   4096 May 12 23:14 ./drwxr-xr-x  3 root root   4096 May 12 23:14 ../drwxr-xr-x  3 root root   4096 May 13 01:07 bin/-rw-r--r--  1 root root 548739 Feb 15 12:52 CHANGES.txtdrwxr-xr-x 13 root root   4096 Feb 16 12:23 contrib/drwxr-xr-x  4 root root   4096 May 12 23:14 dist/drwxr-xr-x 19 root root   4096 May 12 23:14 docs/drwxr-xr-x  7 root root   4096 May 12 23:14 example/drwxr-xr-x  2 root root  36864 May 12 23:14 licenses/-rw-r--r--  1 root root  12646 Jan 24 10:09 LICENSE.txt-rw-r--r--  1 root root 589819 Feb 16 10:19 LUCENE_CHANGES.txt-rw-r--r--  1 root root  26529 Jan 24 10:09 NOTICE.txt-rw-r--r--  1 root root   7162 Feb  7 04:04 README.txtdrwxr-xr-x 11 root root   4096 May 12 23:22 server/
 以上目录

现在就可以直接开启solr了   bin/solr start -p 8080 

root@ubuntu:/usr/local/zx/solr/solr# bin/solr start -p 8080 Waiting up to 30 seconds to see Solr running on port 8080 [|]  Started Solr server on port 8080 (pid=6557). Happy searching!

happy searching  服务开启成功.  其中-p 是设置访问端口号  如果没有指定 8983为默认端口号

访问:自己的路径:8080/solr/admin.html


创建core  bin/solr create -c  coreName

root@ubuntu:/usr/local/zx/solr/solr# bin/solr create -c categrayCopying configuration to new core instance directory:/usr/local/zx/solr/solr/server/solr/categrayCreating new core 'categray' using command:http://localhost:8080/solr/admin/cores?action=CREATE&name=categray&instanceDir=categray{  "responseHeader":{    "status":0,    "QTime":1179},  "core":"categray"}

现在你可以去页面上进行索引新增修改以及检索了


solr自带的分词器对中文的支持并不怎么好.所以我们通常会使用第三方的分词器  我这边使用的是IK分词器.
5.5版本IK分词器下载地址:http://download.csdn.net/detail/ty0415/9448628

下载下来请把压缩包里的stopword.dic   ,    ext.dic     ,      IKAnalyzer.cfg.xml  拷贝出来.接下来就是我们安装分词器的步骤

/usr/local/zx/solr/solr/server/solr-webapp/webapp/WEB-INF
把IK分词器jar包放入 lib中
上面说的三个配置文件放入classes文件夹内(如果没有此文件夹,请创建一个)


接下来要告诉solr我们加入了一个新的分词器  并且分配给这个分词器一个字段类型
drwxr-xr-x 3 root root  4096 May 13 01:06 ./drwxr-xr-x 4 root root  4096 May 12 23:50 ../-rw-r--r-- 1 root root  3974 Jan 24 10:09 currency.xml-rw-r--r-- 1 root root  1348 Jan 24 10:09 elevate.xmldrwxr-xr-x 2 root root  4096 May 13 00:58 lang/-rw-r--r-- 1 root root 29172 May 13 01:06 managed-schema-rw-r--r-- 1 root root   308 Jan 24 10:09 params.json-rw-r--r-- 1 root root   873 Jan 24 10:09 protwords.txt-rw-r--r-- 1 root root 60567 Feb 12 10:58 solrconfig.xml-rw-r--r-- 1 root root   781 Jan 24 10:09 stopwords.txt-rw-r--r-- 1 root root  1119 Jan 24 10:09 synonyms.txtroot@ubuntu:/usr/local/zx/solr/solr/server/solr/product/conf# 


managed-schema 增加如下配置

<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>


现在你就可以去web页面上尝试一把了.

0 0