Facet,单词意思是侧面,平面。哈哈,怎么学英文单词了……
好吧,言归正题,solr的Facet是一个什么东西呢?我个人理解,反映一个搜索词的平面(或者说某一个分组),起到标签聚合统计的功能。举个列子说,像我们公司的电商类网站那样的对搜索结果聚合分类,品牌等属性。如下图
这个是搜索铁观音这个词,统计了分类和品牌2个侧面(分组),铁观音在生活分类下有64个,茗茶里面48……
上面这个说到底,就是某一类型的标签统计,比如xxx年热词等等,只要有记录,也能统计出来,当然,超大数据量提前优化好solr的性能。
介绍了一下facet之后,来说说怎么实现facet。facet的实现其实很简单,主要在搜索参数上带上就OK。
facet=on/true #代表开启facet
facet.field=cate #代表要统计的面(分组),比如上面的分类,品牌,可以多次出现
facet.limit =20 #每个分组最多返回条数
facet.mincount = 1 #这个表示分组下某一条目的最小数据量
facet.missing = on/true #统计null的值
facet.method = #默认为fc, fc表示Field Cache
比如:http://localhost/product/select/?q=铁观音&facet=on&facet.field=category&facet.field=brand&facet.mincount=1在搜索结果中返回xml的facet结果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
< lst name = "facet_counts" >
< lst name = "facet_queries" />
< lst name = "facet_fields" >
< lst name = "category" >
< int name = "2742" >64</ int >
< int name = "793" >48</ int >
< int name = "2741" >12</ int >
< int name = "801" >6</ int >
< int name = "1087" >1</ int >
</ lst >
< lst name = "brand" >
< int name = "229" >74</ int >
< int name = "227" >16</ int >
< int name = "270" >13</ int >
< int name = "317" >10</ int >
< int name = "0" >4</ int >
< int name = "165" >4</ int >
< int name = "203" >3</ int >
< int name = "147" >2</ int >
< int name = "166" >2</ int >
< int name = "217" >1</ int >
< int name = "342" >1</ int >
< int name = "343" >1</ int >
</ lst >
</ lst >
|
<lst name="category"> 分组名
<int name="2742">64</int> 分组内条目,name表示条目,64是统计结果数。
用solrJ那就更简单了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
ModifiableSolrParams params = new ModifiableSolrParams();
params.set( "fq" , fq);
params.set( "facet" , "on" );
params.set( "facet.field" , "category" , "brand" );
params.set( "facet.mincount" , "1" );
params.set( "facet.limit" , "15" );
params.set( "q" , "铁观音" );
QueryResponse qresponse = queryserver.query(params); FacetField facetField = qresponse.getFacetField(Facet_CATEGORY); List<Count> counts = null ;
if (facetField != null ) {
counts = facetField.getValues();
if (counts != null ) {
for (Count count : counts) {
System.out.println(count.getName()+ " " +count.getCount());
}
}
} |
Facet应用很简单,schema上的索引字段都可以作为面统计
相关推荐
solr facet 笔记
Solr实现电扇站内搜索Solr实现电扇站内搜索Solr实现电扇站内搜索Solr实现电扇站内搜索
solrj的facet查询总结
我们网站搜索如果数据量大的话,我们使用数据库直接查搜索会很慢,而且由于不能自动分词,结果往往不是很理想,现在我提供了一个例子,内含详细操作步骤和简单增删改查 Solr是一个独立的企业级搜索应用服务器,它...
《解密搜索引擎技术实战》第八章代码,用solr实现的搜索引擎。
使用Solr实现电商网站中商品信息搜索功能。 1、 可以根据关键字搜索商品信息 2、 可以根据商品分类、价格过滤搜索结果 3、 可以根据价格进行排序 4、 实现分页
通过solr实现电商搜索排名打分,排序,可自定义打分规则
包括部署、配置、Solr Core、Solr DIH、全量导入、增量导入、索引、中文分词、查询组件、Solr Facet、高亮、查询建议,以及企业如何在真实的项目中使用Solr。不仅讲解了基本概念和使用方法,而且还分析了各组件的...
基于Solr的分布式实时搜索模型研究与实现
solr.warsolr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包solr.war包...
包括部署、配置、Solr Core、Solr DIH、全量导入、增量导入、索引、中文分词、查询组件、Solr Facet、高亮、查询建议,以及企业如何在真实的项目中使用Solr。不仅讲解了基本概念和使用方法,而且还分析了各组件的...
该文档主要用于创建在solr中创建hbase的二级索引的教程,新建solr的分片,以及后续修改和新建配置文件等,仅供参考
使用java实现solr-7.1.0的api和solr最新支持的sql查询.使用java实现solr-7.1.0的api和solr最新支持的sql查询.
在本套课程中,我们将全面的讲解Solr,从Solr基础到Solr高级,再到项目实战,基本上涵盖了Solr中所有的知识点。 主讲内容 章节一:Solr基础(上) 1. 环境搭建 2. 核心讲解 3. 数据导入 4. 各种中文分析器 章节二:...
solr
solr使用和原理 简单明了的介绍了solr的使用和原理,及其部署方式,适合初学者第一次部署
solr定时索引使用到的定时调度器jar包, 可使用于solr7.x版本
solr
Apache Solr lucene 搜索模块设计实现 Solr 模块 架构 lucene 搜索
lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用lucene,solr的使用