首页 技术 正文
技术 2022年11月15日
0 收藏 582 点赞 4,350 浏览 920 个字

提升软件性能,通常喜欢去调整各种启动参数,这没有多大意义,小伎俩。 性能优化要从架构和策略入手,才有可能得到较大的收益

Solr的查询是基于Field的,以Field为基本单元,例如一个文章站要索引

  1. classArticle
  2. {
  3.    String title;
  4.    String content;
  5.    String tags;
  6. }

查询参数: q=title:big && content:six

Solr会顺序执行两次 field查询 ,这个开销非常大。 实际例子 :50万条记录,一次在6,7个字段上检索,24 core的服务器也需要10-20ms

如果把title和content 合并,那只需要查询一次,性能可以提升50%

在生成索引xml的时候,把title和content填入同一个字段,就能达到这种效果,但是产生新的问问题

无法对title和content的查询分别指定权重了,一般来说,title的权重要高于content

Solr给出一种解决方法:在schema中使用 copyField

上述的Article Schema可以写成如下这种格式,就能达到效果

  1. <fieldname=”title”type=”text_general”indexed=”true”stored=”true”/>
  2. <fieldname=”content”type=”text_general”indexed=”true”stored=”true”/>
  3. <fieldname=”tags”type=”text_general”indexed=”true”stored=”true”/>
  4. <fieldname=”text”type=”text_general”indexed=”true”stored=”false”multiValued=”true”/>
  5. <copyFieldsource=”title”dest=”text”/>
  6. <copyFieldsource=”content”dest=”text”/>
  7. <copyFieldsource=”tags”dest=”text”/>

这种schema定义方式,既可以对单个field指定查询权重,也可以在泛查询的时候提升性能,同时生成索引数据的时候不需要多写任何代码

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295