当前位置: 首页 > news >正文

郑州公司网站平台建设淘宝店铺可以做网站优化么

郑州公司网站平台建设,淘宝店铺可以做网站优化么,wordpress文章幻灯片,网站建设补充协议模板文章目录 概念全文搜索相关技术Elasticsearch概念近实时索引类型文档分片(Shard)和副本(Replica) 下载启用SpringBoot整合引入依赖创建文档类创建资源库测试文件初始化数据创建控制器 问题参考 概念 全文搜索#xff08;检索#xff09;#xff0c;工作原理#xff1a;计算… 文章目录 概念全文搜索相关技术Elasticsearch概念近实时索引类型文档分片(Shard)和副本(Replica) 下载启用SpringBoot整合引入依赖创建文档类创建资源库测试文件初始化数据创建控制器 问题参考 概念 全文搜索检索工作原理计算机索引程序扫描文章中的每一个词对每一个词建立一个索引指明出现次数和位置。查询时通过索引进行查找类似于查字典。 因为是通过索引在查速度较于通过sql查会快很多。 具体过程如下 1、建文本库 2、建立索引 3、执行搜索 4、过滤结果 全文搜索相关技术 Lucenehttps://lucene.apache.org/core/ Solrhttps://solr.apache.org/ Elasticsearchhttps://www.elastic.co/cn/elasticsearch Lucene是搜索引擎Elasticsearch和Solr都是基于Lucene之上实现的全文检索系统 Elasticsearch和Solr对比版本比较老做参考即可 Elasticsearch 概念 一个高度可扩展的开源全文搜索和分析引擎它允许用户快速地、近实时地对大数据进行存储、搜索和分析它通常用来支撑有复杂的数据搜索需求的企业级应用 。 近实时 近实时而不是实时 索引文档到可搜索的时间有一个轻微的延迟通常为1秒。之所以会有这个延时主要考虑查询的性能优化。 想要实时就得刷新要么是牺牲索引的效率每次索引之后刷新要么就是牺牲查询的效率每次查询之前都进行刷新 Elasticsearch取了折中每隔n秒自动刷新 Elasticsearch 索引新文档后不会直接写入磁盘而是首先存入文件系统缓存之后根据刷新设置定期同步到磁盘。索引我们改完内容不会立即被搜索出来但是会在1秒内可见 索引 相似文档的集合 类型 对一个索引中包含的文档进一步细分 文档 索引的基本单位与索引中的一个类型相对应 分片(Shard)和副本(Replica) 数据量较大时把索引分成多个分片来存储索引的部分数据提高性能/吞吐量 为了安全一个分片中的数据至少有一个副本 下载 https://www.elastic.co/cn/downloads/elasticsearch 注意版本spring-boot2.x不要用最新版本用7.x.x 启用 命令行进入bin目录执行elasticsearch启动服务Ctrl/command C停止服务 启用localhost:9200测试Elasticsearch节点是否正在运行可能会遇到安全认证问题见问题部分 {name: zhangxingxingdeMacBook-Pro.local,cluster_name: elasticsearch,cluster_uuid: DwgXhzhwQ9WS0drElcEZmg,version: {number: 7.11.1, // 当前elasticsearch版本build_flavor: default,build_type: tar,build_hash: ff17057114c2199c9c1bbecc727003a907c0db7a,build_date: 2021-02-15T13:44:09.394032Z,build_snapshot: false,lucene_version: 8.7.0, //lucene版本minimum_wire_compatibility_version: 6.8.0,minimum_index_compatibility_version: 6.0.0-beta1},tagline: You Know, for Search }SpringBoot整合 引入依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-elasticsearch/artifactId /dependency创建文档类 Document(indexName blog) Table(name article) public class EsBlog implements Serializable {private static final long serialVersionUID 1L;Id // 主键private String id;private String title;private String author;private String content;protected EsBlog(){}public EsBlog(String title, String author, String content){this.title title;this.author author;this.content content;}......Overridepublic String toString(){return String.format(Article[id%s, title%s, author%s, content%s],id, title, author, content);} }创建资源库 Repository public interface EsBlogRepository extends ElasticsearchRepositoryEsBlog, String {PageEsBlog findByTitleContainingOrAuthorContainingOrContentContaining(String title, String author, String content, Pageable pageable); }注意在创建启动类中进行包扫描否则注入的时候找不到bean EnableJpaRepositories(basePackages com.xxx.xxx)测试文件初始化数据 RunWith(SpringRunner.class) SpringBootTest(classes SpringApplicationSock.class) // 启动sping-boot引入IOC public class EsBlogRepositoryTest {Autowiredprivate EsBlogRepository esBlogRepository;Beforepublic void initRepositoryData(){// 清除所有数据esBlogRepository.deleteAll();// 初始化数据,存入es存储库esBlogRepository.save(new EsBlog(静夜思, 李白, 床前明月光疑是地上霜。举头望明月低头思故乡。));esBlogRepository.save(new EsBlog(咏柳, 贺知章, 碧玉妆成一树高万条垂下绿丝绦。不知细叶谁裁出二月春风似剪刀。));esBlogRepository.save(new EsBlog(悯农, 李绅, 锄禾日当午汗滴禾下土。谁知盘中餐粒粒皆辛苦。));}Testpublic void testFindDistincEsBlogTitleContainingOrSummaryContainingOrContentContaining(){// 初始化一个分页请求Pageable pageable PageRequest.of(0, 20);String title 咏;String author 王;String content 月;PageEsBlog page esBlogRepository.findByTitleContainingOrAuthorContainingOrContentContaining(title, author, content, pageable);System.out.println(start);for(EsBlog blog : page){System.out.println(blog.toString());}System.out.println(end);} }查看存储库 http://localhost:9200/_cat/indices?v 上述内容通过查询条件只能查出两条数据 查看blog相关信息 http://localhost:9200/blog {blog: {aliases: {},mappings: {properties: {_class: {type: keyword,index: false,doc_values: false},author: {type: text,fields: {keyword: {type: keyword,ignore_above: 256}}},content: {type: text,fields: {keyword: {type: keyword,ignore_above: 256}}},title: {type: text,fields: {keyword: {type: keyword,ignore_above: 256}}}}},settings: {index: {routing: {allocation: {include: {_tier_preference: data_content}}},refresh_interval: 1s,number_of_shards: 1,provided_name: blog,creation_date: 1703233943853,store: {type: fs},number_of_replicas: 1,uuid: 0ELJkqnmTg-tDwritULELA,version: {created: 7110199}}}} }创建控制器 RestController RequestMapping(/blogs) public class EsBlogController {Autowiredprivate EsBlogRepository esBlogRepository;GetMappingpublic ListEsBlog list(RequestParam(value title, required false, defaultValue ) String title,RequestParam(value author, required false, defaultValue ) String author,RequestParam(value content, required false, defaultValue ) String content,RequestParam(value pageIndex, required false, defaultValue 0) int pageIndex,RequestParam(value pageSize, required false, defaultValue 10) int pageSize){Pageable pageable PageRequest.of(pageIndex, pageSize);PageEsBlog page esBlogRepository.findByTitleContainingOrAuthorContainingOrContentContaining(title, author, content, pageable);return page.getContent();} }问题 1、ElasticSearch服务正常启动但是在浏览器上无法访问http://localhost:9200最新版本可能会有这个问题 received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress/[0:0:0:0:0:0:0:1]:9200, remoteAddress/[0:0:0:0:0:0:0:1]:63470} 解决方法 ElasticSearch默认开启了安全认证需要将安全认证关掉 config/elasticsearch.yml将下面两处的true改为false 2、启动test提示Unsatisfied dependency expressed through field ‘esBlogRepository’; 未启动spring boot没有IOC https://blog.csdn.net/weixin_43801567/article/details/96643032 3、Unable to parse response body for Response{requestLinePOST /blog/_doc?timeout1m HTTP/1.1, hosthttp://localhost:9200, responseHTTP/1.1 201 Created} es服务器的响应程序解析不了有可能是spring-boot版本低了 spring-boot 2.7.3es:8.11.3 会有问题将es改为7.11.1正常 参考 https://blog.csdn.net/weixin_38201936/article/details/121746906 https://blog.csdn.net/qq_50652600/article/details/125521823
http://www.w-s-a.com/news/362225/

相关文章:

  • 企业网站开发文献综述加盟网网站建设策划书
  • 最便宜的网站空间网站建设和app开发
  • 承装承修承试材料在哪个网站做如何用虚拟主机建设网站
  • 如何建一个外贸网站网页设计零基础学习课程
  • 营销型外贸网站广州昆明建设网站制作
  • 网页制作网站素材项目建设全过程管理
  • 正能量网站下载柬埔寨网赌网站开发
  • 如何免费建设公司网站广州传业建设有限公司网站
  • 织梦做的网站快照被攻击张家口网站建设公司
  • 平顶山公司网站建设南昌网站seo多少钱
  • 网站开发要先买服务器吗建设婚恋网站用什么搭建
  • 我想自己在网站上发文章 怎样做wordpress站点安装
  • 北京模板网站开发全包昆明网站开发正规培训
  • 西咸新区建设环保网站谷歌风格wordpress
  • 嘉兴港区建设局网站2018年网站开发
  • 网站里图片做超链接专业开发网站报价单
  • server2003网站建设做销售记住这十句口诀
  • microsoft免费网站网站后台登陆路径
  • 贵州住房和城乡建设局网站做网站排名费用多少钱
  • 现在个人做网站还能盈利吗xampp用wordpress
  • 做网站 租服务器温岭建设公司网站
  • 四川住房和城乡建设厅网站官网做网站最贵
  • 右玉网站建设四川林峰脉建设工程有限公司网站
  • 网站推广小助手杭州百度百家号seo优化排名
  • 怎么做网站搜索框搜索网站备案拍照背景幕布
  • 建设部网站城市规划资质标准伊春网络推广
  • 如何设计酒店网站建设深圳市房地产信息系统平台
  • 伍佰亿网站怎么样网站建设前台后台设计
  • 做整装的网站北京哪个网站制作公司
  • 建设赚钱的网站福州便民生活网