一、Facet介绍
solr facet 是solr搜索的一大特色,facet不好翻译,有说是垂直搜索,有说是分片搜索,但都不是很好,还是懒得翻译了,就叫facet ,具体功能看下面的例子意会吧。
比如你上淘宝,输入“笔记本”进行搜索,就会出现品牌分类,价格范围等分类,这个就叫facet了。这个例子也许好不是那么准确的描述facet,不过基本上就是这个意思。对输入关键字后搜索出来的结果再进行分类。
二、 Facet查询
进行Facet查询需要在请求参数中加入”facet=on”或者”facet=true”只有这样Facet组件才起作用.
1. Field Facet
Facet字段通过在请求中加入”facet.field”参数加以声明,如果需要对多个字段进行Facet查询,那么将该参数声明多次.比如
http://localhost:8983/solr/select?q=联想&facet=on&facet.field=cpu&facet.field=videoCard
查询返回
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
<lst name="cpu">
<int name="Intel 酷睿2双核 T6600">48</int>
<int name="Intel 奔腾双核 T4300">28</int>
<int name="Intel 酷睿2双核 P8700">18</int>
<int name="Intel 酷睿2双核 T6570">11</int>
<int name="Intel 酷睿2双核 T6670">11</int>
<int name="Intel 奔腾双核 T4400">9</int>
<int name="Intel 酷睿2双核 P7450">9</int>
<int name="Intel 酷睿2双核 T5870">8</int>
<int name="Intel 赛扬双核 T3000">7</int>
<int name="Intel 奔腾双核 SU4100">6</int>
<int name="Intel 酷睿2双核 P8400">6</int>
<int name="Intel 酷睿2双核 SU7300">5</int>
<int name="Intel 酷睿 i3 330M">4</int>
</lst>
<lst name="videoCard">
<int name="ATI Mobility Radeon HD 4">63</int>
<int name="NVIDIA GeForce G 105M">24</int>
<int name="NVIDIA GeForce GT 240M">21</int>
<int name="NVIDIA GeForce G 103M">8</int>
<int name="NVIDIA GeForce GT 220M">8</int>
<int name="NVIDIA GeForce 9400M G">7</int>
<int name="NVIDIA GeForce G 210M">6</int>
</lst>
</lst>
<lst name="facet_dates"/>
</lst>
各个Facet字段互不影响,且可以针对每个Facet字段设置查询参数.以下介绍的参数既可以应用于所有的Facet字段,也可以应用于每个单独的Facet字段.应用于单独的字段时通过
f.字段名.参数名=参数值
这种方式调用.比如facet.prefix参数应用于cpu字段,可以采用如下形式
f.cpu.facet.prefix=Intel
三、facet 参数
facet的参数见solr官方wiki http://wiki.apache.org/solr/SimpleFacetParameters
说明:
搜索结果按照Facet的字段分组并统计
facet 参数字段要求
字段必须被索引
#.field Facet
facet=on 或 facet=true
1.facet.field
分组的字段
2.facet.prefix
表示Facet字段前缀
3.facet.limit
Facet字段返回条数
4.facet.offict
开始条数,偏移量,它与facet.limit配合使用可以达到分页的效果
5.facet.mincount
Facet字段最小count,默认为0
6.facet.missing
如果为on或true,那么将统计那些Facet字段值为null的记录
7.facet.method
取值为enum或fc,默认为fc, fc表示Field Cache
8.facet.enum.cache.minDf
当facet.method=enum时,参数起作用,文档内出现某个关键字的最少次数
例:
&facet=on
&facet.field=city_id
&facet.field=address
http://localhost:8983/solr/select/?q=*:*&indent=on&facet=on&facet.field=unit_price&facet.field=developer_id
返回结果facet_counts:
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
<lst name="unit_price">
<int name="9100.0">2</int>
<int name="1100.0">1</int>
</lst>
<lst name="developer_id">
<int name="101">2</int>
<int name="100">1</int>
</lst>
</lst>
<lst name="facet_dates"/>
</lst>
#.Date Facet
日期类型的字段
1.facet.date
表示需要Data Facet的字段名
2.facet.date.start
起始时间.时间一般格式为"1995-12-31T12:59:59Z"
另外可以使用"NOW","YEAR","MONTH"等
3.facet.date.end
结束时间
4.facet.date.gap
时间间隔
5.facet.date.hardend
true|false
6.facet.date.other
before|after|between|none|all 默认为none
before会对start之前的值做统计
after会对end之后的值做统计
between会对start至end之间的值做统计,如果hardend为true的话,那么改值就是各个时间段统计值的和
none 表示该项禁用
all 表示before,after,all都会统计
例:
$facet=on
&facet.date=date
&facet.date.start=2009-1-1T0:0:0Z
&facet.date.end=2010-1-1T0:0:0Z
&facet.date.gap=;1MONTH
&facet.date.other=all
7.facet.date.include
lower|upper|edge|outer|all
#.Facet Query
facet.query 可以对任意的字段进行筛选
例:
&facet=on
&facet.query=date:[2009-1-1T0:0:0Z TO 2010-1-1T0:0:0Z]
- 大小: 76.2 KB
分享到:
相关推荐
本书立足全球视野,综合Solr技术的发展和应用、从业人员的学习曲线,以及中英文资料的供给情况,给自己设定了一个极高的目标:力争在内容的全面性、系统性、深浅度和实战性上概括所有的同类书。从完成的结果上来看,...
本书立足全球视野,综合Solr技术的发展和应用、从业人员的学习曲线,以及中英文资料的供给情况,给自己设定了一个极高的目标:力争在内容的全面性、系统性、深浅度和实战性上概括所有的同类书。从完成的结果上来看,...
solr facet 笔记
3.2.2 Facet 3 3.3.3 Document 6 3.3.4 Field 6 3.3.5 IndexWriter 6 3.3.6 IndexSearcher 6 3.3.7 Directory 6 3.3.8 Segment 7 3.3.9 QueryParser 7 3.3.10 Hits 7 4.应用示例 7 4.1 创建索引 7 4.1 删除索引 7 ...
Solr是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口。用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引;也可以通过Http G Solr et操作提出查找请求,并得到XML...
博客文章:运行示例使用运行Solr。 $ make start-solr 或使用docker 。 $ PODMAN=docker make start-solr 运行API // build the api$ go build -v -o api// start the api with the initialization options$ ./api ...
7. SolrJ 章节三:Solr高级(上) 1. Solr Cloud 2. 函数查询 3. 地理位置查询 4. JSON Facet 章节四:Solr高级(下) 1. 深度分页 2. Solr Join查询 3. 相关度排序 4.Solr缓存 5.Spring Data Solr 章节五:综合...
solrj的facet查询总结
演示了怎样使用easysolr.net开发facet功能,怎样模糊查询,精确查询。
排序 / 高亮 / facet / spellcheck:拼写检查 / spatial:空间搜索 / 检索运算符:
Solr 入门资料 环境配置 facet
pn-dispatcher -Java servlet,用于持久性,检索和显示papyri.info记录曾经由pn-indexer,pn-mapping,pn-lemmas,pn-solr和pn-xslt文件处理过。 这里包含三个servlet: info.papyri.dispatch.browse....
当使用 Java 和 JVM 的时候使用比较多的是 Lucene,Elasticsearch 和 Solr。但是有时候不想要那么多依赖,想要避免外部服务,简单编译部署就可以运行。所以 Couchbase 团队就构建了一个 Go 库,支持大部分 Lucene ...
在 Django-haystack 中可以使用多种搜索索引系统,例如 Solr 或 ElasticSearch。 安装 xmlfacets 需要 Python 2.7 和 PostgreSQL。 要设置本地开发环境,请安装 并确保您具有以下依赖项 libxml2 libxslt 可选:...