https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040
第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第五天】
第04项目:淘淘商城(SpringMVC+Spring+Mybatis) 的学习实践总结【第六天】
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第七天】(redis缓存)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第八天】(solr服务器搭建、搜索功能实现)
第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第八天】(solr服务器搭建、搜索功能实现)
今天内容:
商品搜索功能:
1、使用solr实现。
2、搭建搜索服务层。
3、使用poratl调用搜索服务,实现商品搜索。
03.solr配置中文分析器及业务字段
04.索引库的维护
05.solrJ维护索引库
<!-- solrJ客户端 --> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>7.7.2</version> </dependency>
HttpSolrClient solrServer = new HttpSolrClient.Builder("http://192.168.179.128:8080/solr/collection1").build();
package com.taotao.rest.jedis;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.common.SolrInputDocument;
import org.junit.Test;
public class SolrJTest {
@Test
public void addDocument() throws Exception {
// https://www.cnblogs.com/jepson6669/p/9142676.html#headline1-11
// 创建一连接,solr7的URL需要在solr/后面补全core的名称
HttpSolrClient solrServer = new HttpSolrClient.Builder("http://192.168.179.128:8080/solr/collection1").build();
//创建一个文档对象
SolrInputDocument document = new SolrInputDocument();
document.addField("id", "test001");
document.addField("item_title", "测试商品001");
document.addField("item_price", 123456);
//把文档对象写入索引库
solrServer.add(document);
//提交
solrServer.commit();
//Solr中没有update,只需要id一致覆盖重写即可
}
@Test
public void deleteDocument() throws Exception {
//创建一连接Solr4
//SolrServer solrServer = new HttpSolrServer("http://192.168.25.154:8080/solr");
//创建一连接Solr7
HttpSolrClient solrServer = new HttpSolrClient.Builder("http://192.168.179.128:8080/solr/collection1").build();
//solrServer.deleteById("test001");
solrServer.deleteByQuery("*:*");
solrServer.commit();
}
}
===============================================================
在VMware® Workstation 中的CentOS7系统虚拟机下安装jdk-8u231-linux-x64.tar.gz
win10环境下使用VM15PRO虚拟机CentOS7系统下安装tomcat8.5
拼音分析器的安装 :https://www.cnblogs.com/jepson6669/p/9134652.html
未完待续。。。