Reputation: 1552
Here I'm trying to get the count of most frequent items in a time range, vs items in all time:
{
"query": "{!tag=time}time_in_seconds:[1589453460 TO 1589539860]",
"facet": {
"topItems": {
"type": "field",
"limit": 10,
"field": "item_name",
"facet": {
"allItems": {
"type": "query",
"q": "{!ex=time}*:*"
}
}
}
}
}
The problem is, in the query result, topItems count is always the same with allItems count, since excluding filters is somehow not working:
"facets": {
"count": 8263088,
"topItems": {
"buckets": [
{
"val": "item 1",
"count": 14945,
"allItems": {
"count": 14945
}
},
{
"val": "item 2",
"count": 14060,
"allItems": {
"count": 14060
}
}...
From what I understand in docs, the inline facet should show total item count without the time filter. I am sure there are additional items outside of that time range.
Btw using Solr v. 8.4
-- Tried this too:
{
"query": "*:*",
"filter":["{!tag=time}time_in_seconds:[1589453460 TO 1589539860]"]
"facet": {
"topItems": {
"type": "field",
"limit": 10,
"field": "item_name",
"facet": {
"allItems": {
"type": "query",
"q": "{!ex=time}*:*"
}
}
}
}
}
result is the same sadly.
Upvotes: 1
Views: 358
Reputation: 1552
Digged a bit more into the docs, apparently it must be done like this:
{
"query": "*:*",
"filter": [{"#time":"time_in_seconds:[1589453460 TO 1589539860]"}],
"facet": {
"topItems": {
"type": "field",
"limit": 10,
"field": "item_name",
"facet": {
"allItems": {
"type": "query",
"q": "*:*",
"domain": {"excludeTags":"time"}
}
}
}
}
}
Upvotes: 1