[英]SOLR - group by field and then get distinct value by another field
我正在使用apache solr來搜索記錄。 就我而言,我有一個表,該表具有列類別和子類別等。
我想按類別分組,然后從分組結果中獲得不同的子類別列表。 在Apache Solr中可能嗎?
如果是,請幫助我解決此問題。 提前致謝。
您可以使用透視面來實現:
facet=on&facet.pivot=category,subcategory
這將使您全面了解每個類別的所有子類別。
您還可以使用Facet JSON API 。 該頁面采用的示例:
top_categories:{
type: terms,
field: category,
limit: 5,
facet:{
top_subcategories:{
type: terms,
field: subcategory,
limit: 20
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.