Skip to content

Commit

Permalink
SOLR-17477: adding changes and one more demo test
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhludnev committed Oct 21, 2024
1 parent 90a251c commit 86a7941
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Improvements
* SOLR-17397: SkipExistingDocumentsProcessor now functions correctly with child documents. (Tim Owens via Eric Pugh)
* SOLR-17180: Deprecate snapshotscli.sh in favour of bin/solr snapshot sub commands. Now able to manage Snapshots from the CLI. HDFS module specific snapshot script now ships as part of that module in the modules/hdfs/bin directory. (Eric Pugh)

* SOLR-17477: Let to extend FacetModule aka JSON DSL Facet (Tim Owen, Christine Poerschke via Mikhail Khludnev)

Optimizations
---------------------
* SOLR-14985: Solrj CloudSolrClient with Solr URLs had serious performance regressions (since the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.apache.solr.search.function;

import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SyntaxError;
import org.apache.solr.search.facet.FacetField;
import org.apache.solr.search.facet.FacetParser;
import org.apache.solr.search.facet.FacetRequest;
import org.junit.BeforeClass;

import java.util.Collections;
import java.util.Map;


public class CustomParseHandlerTest extends SolrTestCaseJ4 {

public static final FacetField FACET_FIELD_STUB = new FacetField();

static class CustomParseHandler implements FacetParser.ParseHandler {
@Override
public Object doParse(FacetParser<?> parent, String key, Object args) {
assertEquals("arg", args);
return FACET_FIELD_STUB;
}
}

@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml", "schema.xml");
}

@Override
public void setUp() throws Exception {
super.setUp();
FacetParser.registerParseHandler("custom", new CustomParseHandler());
}

public void testCustomParseHandler() {
SolrQueryRequest req = req();
ResponseBuilder rsp = new ResponseBuilder(req, new SolrQueryResponse(), Collections.emptyList());

FacetRequest facetRequest = FacetRequest.parse(rsp.req, Map.of("bogus",Map.of("custom","arg")));
assertEquals(FACET_FIELD_STUB, facetRequest.getSubFacets().get("bogus"));
}
}

0 comments on commit 86a7941

Please sign in to comment.