Isn't this already possible -- allthough kludgy and totally undocumented -- because of how FacetParser delegates to FunctionQParser.parseAgg(...) ?
That method delegates to SolerCore.getValueSourceParser(id) using an "aggregation id" that has "agg_" prepended to it (unless the user already specified it) and then asserts that the ValueSourceParser it gets back produces an AggValueSource. So if you want to write a custom AggValueSource parsers that you can use in facet queries with the name "custom", just implement it as a ValueSourceParser (that returns an AggValueSource) and register it in solrconfig.xml as "agg_custom") It's not pretty, but it should work -- it's how all the built in JSON facet aggregations work, but w/implicit registration... hossman@slate:~/lucene/solr [j11] [branch_9x] $ grep "agg_" ./solr/core/src/java/org/apache/solr/search/ValueSourceParser.java "agg_count", "agg_unique", "agg_uniqueBlock", "agg_hll", "agg_sum", "agg_avg", "agg_sumsq", "agg_variance", "agg_stddev", "agg_missing", "agg_countvals", addParser("agg_multistat", new ValueSourceParser() { "agg_min", "agg_max", "agg_percentile", "agg_" + RelatednessAgg.NAME, : Date: Thu, 21 Nov 2024 17:03:35 +0300 : From: Mikhail Khludnev <m...@apache.org> : Reply-To: dev@solr.apache.org : To: dev@solr.apache.org : Subject: Give a user to introduce new facet types in JSON Facet : : Hello : This question is a spin off from https://github.com/apache/solr/pull/2742/. : PR#2742 is about deploying custom AggValueSource parsers and invoke it via : { : type:func, : func:custom,.. : } : The question is, how user can deploy own facet {type:custom}? see : https://solr.apache.org/guide/solr/latest/query-guide/json-facet-api.html#types-of-facets : : I see two options: : - introduce a new extension point: FacetParser it's a kind of sibling for : QParserPlugin. My concerns are: There are some boilerplates around it e.g. : support new tag in solrconfig.xml, then support it in Config API, what : else? Then, it's going to be an extension point for the FacetModule : component, which who knows _will be with us forever_ you know. : - make some surgery over FacetModule to make it subclassable, i.e. a user : creates a subclass of FacetModule overriding parseFacetOrStat() : <https://github.com/apache/solr/blob/b76a29d17c874806e3b6516810772e2238e93098/solr/core/src/java/org/apache/solr/search/facet/FacetParser.java#L141> : and deploy it via existing plugin/module/configAPI. : Note: the first attempt to make FacetModule subclassable was really scary : https://github.com/apache/solr/pull/2865 the problem deserves more efforts. : : Which of these paths would you like to pursue? : : -- : Sincerely yours : Mikhail Khludnev : -Hoss http://www.lucidworks.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@solr.apache.org For additional commands, e-mail: dev-h...@solr.apache.org