lxy777 发表于 2017-12-19 14:28:46

solr 分面搜索(转载)

  原文地址:http://blog.csdn.net/bingduanlbd/article/details/52199347
  分面搜索(Faceting)基于索引词项对搜索结果进行分类,同时返回每个分类对应的文档数。用户可以可以分类缩小结果范围。下图是一个结果汇总的例子:
  Amazon的搜索也提供了非常优秀的分面及相应的过滤:
  环境
  Solr的发行版自带了一些很好的例子,使用这些例子研究Solr的各种特性非常合适。我们这里使用Solr自带的techproducts索引作为例子。启动solr:
  solr -e techproducts -p 8984

[*]1  通用参数
[*]facet: true/false 是否开启faceting计数
[*]facet.query: 指定计数防暑,语法跟Solr正常的查询一致。默认情况上检查字段唯一term并返回计数,相当于count(distinct field)
  Field-value>  主要参数:
[*]facet.field: 指定字段  查询:
  http://localhost:8984/solr/techproducts/select?q=price:&fl=id,name,price&facet=true&facet.field=cat
[*]1
  Range>  主要参数:
[*]facet.range: 指定字段
[*]facet.range.start:区间开始值
[*]facet.range.end: 区间结束值
[*]facet.range.gap:步长  http://localhost:8984/solr/techproducts/select?q=price:&fl=id,name,price&facet=true&facet.field=cat&facet.range=price&f.price.facet.range.start=0.0&f.price.facet.range.end=1000.0&f.price.facet.range.gap=100
[*]1
  Interval>  主要参数:
[*]facet.interval:指定字段
[*]facet.interval.set: 间隔设置  http://localhost:8984/solr/techproducts/select?q=*:*&fl=id,name,price&facet=true&facet.field=cat&facet.interval=price&f.price.facet.interval.set=&f.price.facet.interval.set=(10,100]
[*]1  参考资料
  官方文档:
  https://cwiki.apache.org/confluence/display/solr/Faceting
页: [1]
查看完整版本: solr 分面搜索(转载)