Reputation: 7657
I am storing documents with text Content
and with different Tags
. When searching I am using a filter query to remove duplicates: q=*:*&fq={!collapse field=Content}
Next, I want to show the number of documents in each group for which I am using following facet query: q=*:*&facet=true&facet.field=Tags
The problem are identical documents which are tagged with different Tags
. E.g.
I have document A
indexed four times; twice with tag x
and twice tag y
. I want to obtain a table like:
+-------------+
| Tag Count |
+-------------+
| x 1 |
| y 1 |
+-------------+
So I tried to combine both queries: q=*:*&facet=true&facet.field=Tags&fq={!collapse field=Content}
.
However, this will first apply the filter query first and then perform facetting, resulting in:
+----------------+
| Tag Count |
+----------------+
| x 0 (or 1) |
| y 1 (or 1) |
+----------------+
So, I want to apply the filter query for each facet separately. How is this possible? There is no facet.fq
parameter. And facet.query={!collapse field=Content}Tags
gives me SolrServerException: No live SolrServers available to handle this request
.
Upvotes: 0
Views: 1055
Reputation: 15791
if I understand correctly you want 'count of unique Content per Tag', correct? if so, json facets will do this:
curl http://.../query -d 'q=*:*&json.facet={
tags:{terms:{
field : Tag,
facet:{ "unique" : "unique(Content)" }
}}
}'
Upvotes: 1