You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "mkhludnev (via GitHub)" <gi...@apache.org> on 2024/10/20 11:55:42 UTC
Re: [PR] SOLR-17477: Support custom aggregates in plugin code [solr]
mkhludnev commented on code in PR #2742:
URL: https://github.com/apache/solr/pull/2742#discussion_r1807794964
##########
solr/core/src/java/org/apache/solr/search/facet/FacetParser.java:
##########
@@ -138,21 +139,30 @@ public Object parseFacetOrStat(String key, Object o) throws SyntaxError {
return parseFacetOrStat(key, type, args);
}
+ public interface ParseHandler {
+ Object doParse(FacetParser<?> parent, String key, Object args) throws SyntaxError;
+ }
+
+ private static final Map<String, ParseHandler> REGISTERED_TYPES = new ConcurrentHashMap<>();
+
+ static {
+ ParseHandler fieldParser = (p, k, a) -> new FacetFieldParser(p, k).parse(a);
+ REGISTERED_TYPES.put("field", fieldParser);
+ REGISTERED_TYPES.put("terms", fieldParser);
+ REGISTERED_TYPES.put("query", (p, k, a) -> new FacetQueryParser(p, k).parse(a));
+ REGISTERED_TYPES.put("range", (p, k, a) -> new FacetRangeParser(p, k).parse(a));
+ REGISTERED_TYPES.put("heatmap", (p, k, a) -> new FacetHeatmap.Parser(p, k).parse(a));
+ REGISTERED_TYPES.put("func", (p, k, a) -> p.parseStat(k, a));
+ }
+
+ public static void registerParseHandler(String type, ParseHandler parseHandler) {
Review Comment:
Not sure where to discuss it. But registering anything in static initializer is asking for trouble, imho. I'd rather hookup a component via solrconfig.xml (or a plugin??), which just calls `registerParserHandler()` for custom handlers.
Anyway it's a matter of taste, and should block this PR, unless someone propose to make `FP.registerParserHandler` `protected`. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org