Solr - Aggregate Term Frequency by Group

2019-08-01 14:56发布

Let's say I have the following set of grouped websites crawled and indexed in Solr (latest) :

{
    "id":"1",
    "domain": "http://www.category1website1.com",
    "domainGroup": "Group 1"
},{
    "id":"2",
    "domain": "http://www.category1website2.com",
    "domainGroup": "Group 1"
},{
    "id":"3",
    "domain": "http://www.category2website1.com",
    "domainGroup": "Group 2"
}

I'm looking for a result set that will give me the term frequency in each individual domain but also the aggregated term frequency of that search term (aggregated by domainGroup).

Researching this has lead me to 3 possibilities:

  1. Can be done with Facet Pivot
  2. Can be done with Facet + Term Frequency Vectors
  3. Cannot be done

1 and 2 are different and I'm not sure which would work for me, or worse, neither via "option" 3.

Sorry if it's not clear. I'm trying to retrieve the frequency of the "search term" but I also need the frequency aggregated by domainGroup field. In other words I need to search ALL domains for "search term" in one request and retrieve the frequency of "search term" in NOT ONLY the individual domains (the default), but also the aggregated frequencies for all domainGroups (so the sum of term frequencies in all domains under the same domainGroup).

1条回答
叛逆
2楼-- · 2019-08-01 15:42

I think the Facets with Term frequency Vectors is what you need. Try a query like this:

http://something/solr/select/?qt=tvrh&q=query:http://www.category2website1.com&tv.fl=query&tv.all=true&f.id.tv.tf=true&facet.field=domainGroup&facet=true&facet.limit=-1&facet.mincount=1
查看更多
登录 后发表回答