[ 
https://issues.apache.org/jira/browse/SOLR-14921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17211246#comment-17211246
 ] 

Michael Gibney commented on SOLR-14921:
---------------------------------------

Thanks for raising this, [~gopikannan]. Some context (adapted from a 
[conversation on the dev 
list|http://mail-archives.apache.org/mod_mbox/lucene-dev/202010.mbox/%3CCAF%3DheHGKwGtvq%3DgAndmVrgvo1cxKmzP0neGi17_eoVhubpaBZA%40mail.gmail.com%3E]):

The behavior you're seeking is already achievable by creating multiple 
json.facet queries – {{q="\{!term f=field v='Some term'}"}} – and sorting them 
client-side (if applicable). This works nicely because you're inherently 
dealing with a limited number of values; but it's relatively verbose, and in 
order to logically group related facet queries, I've ended up as a workaround 
nesting them all under a dummy parent facet query ({{q='\*:\*'}}) – not ideal:
{noformat}
json.facet = {
  group: {
    type: query,
    q: "*:*"
    facet: {
      alfa: {
        type: query,
        q: "{!term f=symbol v=alfa}"
      },
      betta: {
        type: query,
        q: "{!term f=symbol v=alfa}"
      },
      with_space: {
        type: query,
        q: "{!term f=symbol v='with,with\',with space'}"
      }
    }
  }
}
{noformat}
What I'm considering as a potential solution could be more generally thought of 
as "templated bucketed facet query", and would probably be more based on the 
{{FacetQueryProcessor}}, and could work for cases other than an explicit term 
list. It might look something like this:
{noformat}
json.facet = {
  symbol: {
    type: template,
    sort: 'count desc',
    template: {
      type: query,
      q: '{!term f=symbol v=$var}' # different semantics from normal parameter 
substitution; alternatives?
    },
    buckets: [
      { var: alfa },
      { var: betta },
      { var: "with,with',with space" }
    ]
  }
}
{noformat}
Syntax could optionally be shortened by convention, e.g.:
{noformat}
json.facet = {
  symbol: {
    type: template,
    sort: 'count desc',
    template: {
      type: query,
      q: '{!term f=symbol v=$var}'
    },
    buckets: [ "alfa", "betta", "with,with',with space" ] # or maybe make the 
key the name of the substitution, i.e. 'var'?
  }
}
{noformat}
But the more full syntax, supporting multiple variables, could be really 
powerful, e.g.:
{noformat}
json.facet = {
  symbol: {
    type: template,
    sort: 'skg desc',
    template: {
      type: query,
      q: '{!v=$arbitrary_q}'
      facet: {
        skg: {
          type: func,
          func: 'relatedness($fore,$back)',
          min_popularity: 0.001
        }
      }
    },
    buckets: [
      {
        val: history_of_science, # bucket label/val
        arbitrary_q: "{!term f=topic_facet v='History of science'}"
      },
      {
        val: accounting,
        arbitrary_q: "{!term f=topic_keyword v=accounting}"
      },
      {
        val: engineering_and_computer_science,
        arbitrary_q: "{!bool should='{!term f=topic_keyword v=engineering}' 
should='{!prefix f=topic_facet v=\'Computer \'}'}"
      }
    ]
  }
}
{noformat}

I'm curious to know your (and others') thoughts on this. I'm also curious to 
know how you'd go about implementing this in a way based on 
{{FacetFieldProcessor}} ... iirc it's mainly focused on collection across the 
domain, and this functionality would essentially turn the request into "all 
refinement requests" -- at which point it's arguably more similar to 
{{FacetQueryProcessor}}.

> terms filter in json.facet
> --------------------------
>
>                 Key: SOLR-14921
>                 URL: https://issues.apache.org/jira/browse/SOLR-14921
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: Facet Module
>            Reporter: gopikannan venugopalsamy
>            Priority: Minor
>
> Hi,
>   In normal facet request below can be used to filter the facet terms. I am 
> not able to do the same using json.facet. It would be useful in case of 
> multivalued field facet and only filtered terms needs to be returned.
>  
> h3. Limiting Facet with Certain Terms
> To limit field facet with certain terms specify them comma separated with 
> {{terms}} local parameter. Commas and quotes in terms can be escaped with 
> backslash, as in {{\,}}. In this case facet is calculated on a way similar to 
> {{facet.method=enum}} , but ignores {{facet.enum.cache.minDf}}. For example:
> {{facet.field=\{!terms='alfa,betta,with\,with\',with space'}symbol}}
> {{}}
> [https://lucene.apache.org/solr/guide/6_6/faceting.html]
>  
> Just like prefix parameter in json.facet I think we can add terms parameter 
> and use it. Something like below.
>  
> json.facet=\{facets:{type:terms,field:field1,terms:"a,b,c"}}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to