安装solr搜索引擎

https://pan.baidu.com/s/1ZmP-9sEjuWOrIIpVOaAXIg

solr的安装

 

 启动solr example目录下

 打开cmd

Java -jar start.jar(启动命令)

创建一个自己需要的slor的核心core(理解为数据库)

  1. 创建一个目录 taotao-solr
  2. taotao-solr下创建一个目录taotao
  3. ./solr目录下的solr.xml复制到taotao-solr目录下
  4. taotao目录下创建两个目录  data(存放数据的和索引的) conf(配置文件)目录
  5. solr/collection1下的文件core.properties 复制到taotao目录 内容改为: name=taotao
  6. solr/collection1/conf目录下schema.xml solrconfig.xml 复制到taotao/conf
  7. Schema.xml 配置的内容

  1. solrconfig.xml中内容

<str name="df">text</str> 替换为<str name="df">title</str>

<searchComponent name="elevator" class="solr.QueryElevationComponent" >注释掉

启动自己的core文件的命令如下

java -Dsolr.solr.home=taotao-solr -jar start.jar

 solr集成中文分词器

IKAnalyzer-2012-4x.jar 放到solr-4.10.2\example\solr-webapp\webapp\WEB-INF\lib

 https://pan.baidu.com/s/1VIUA4mVH9wjsEYBTKVeSLA(jar包)

修改自己的

schema.xml

<solrQueryParser defaultOperator="OR"/> 

这个是配置中文分词器是and还是or的关系,一般电商用and,搜索比较明确

 

猜你喜欢

转载自www.cnblogs.com/sh-0131/p/11743235.html