Pit Digger
Pit Digger

Reputation: 9800

Solr facet column with a condition

I have following facet query which is working fine. However as you can see I need from_usa as one more parameter, I have a country column and it needs to be conditional. Would that be possible ? I cant not use fq filters in this case.

{
            "facet":{
                "total_game_plays" : "count",
                "unique_game_players" : "unique(uuid)",
                "total_play_time":"sum(play_time)",
                //"from_usa": "unique(where country=US)"
            }
}

Upvotes: 0

Views: 248

Answers (1)

MatsLindh
MatsLindh

Reputation: 52822

I assume you're using the JSON facet API from the syntax you've provioded, so a JSON facet query should do what you want:

"from_usa": {
  "type": "query",
  "q": "country:US"
}

Upvotes: 1

Related Questions