Java Code Examples for org.apache.solr.request.SolrRequestHandler#handleRequest()

The following examples show how to use org.apache.solr.request.SolrRequestHandler#handleRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleTreeFacetComponentTest.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test
public void testBadRequest_missingChildField() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "*:*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "{!ftree childField=blah}node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNotNull(rsp.getException());
}
 
Example 2
Source File: SimpleTreeFacetComponentTest.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test
public void testBadRequest_missingLocalParams() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "*:*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNotNull(rsp.getException());
}
 
Example 3
Source File: AbstractXJoinTestCase.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
protected NamedList test(ModifiableSolrParams params, String componentName) {
  SolrCore core = h.getCore();

  SearchComponent sc = core.getSearchComponent(componentName);
  assertTrue("XJoinSearchComponent not found in solrconfig", sc != null);
    
  QParserPlugin qp = core.getQueryPlugin("xjoin");
  assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null);
  
  params.add("q", "*:*");
  params.add("fq", "{!xjoin}" + componentName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.add("responseHeader", new SimpleOrderedMap<>());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

  SolrRequestHandler handler = core.getRequestHandler("standard");
  handler.handleRequest(req, rsp);
  req.close();
  assertNull(rsp.getException());
    
  return rsp.getValues();
}
 
Example 4
Source File: AbstractXJoinTestCase.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
protected NamedList test(ModifiableSolrParams params, String componentName) {
  SolrCore core = h.getCore();

  SearchComponent sc = core.getSearchComponent(componentName);
  assertTrue("XJoinSearchComponent not found in solrconfig", sc != null);
    
  QParserPlugin qp = core.getQueryPlugin("xjoin");
  assertTrue("XJoinQParserPlugin not found in solrconfig", qp != null);
  
  params.add("q", "*:*");
  params.add("fq", "{!xjoin}" + componentName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.add("responseHeader", new SimpleOrderedMap<>());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

  SolrRequestHandler handler = core.getRequestHandler("standard");
  handler.handleRequest(req, rsp);
  req.close();
  assertNull(rsp.getException());
    
  return rsp.getValues();
}
 
Example 5
Source File: Cloud.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @param requestHandler the handler that handles the request
 * @param request the request object to put the params on
 * @param params Solr parameters
 * @return the response
 */
SolrQueryResponse getResponse(SolrRequestHandler requestHandler, SolrQueryRequest request, SolrParams params)
{
    request.setParams(params);
    log.info("Running query " + params.get("q"));
    SolrQueryResponse solrRsp = new SolrQueryResponse();
    requestHandler.handleRequest(request, solrRsp);
    return solrRsp;
}
 
Example 6
Source File: CentroidComponentTest.java    From query-segmenter with Apache License 2.0 5 votes vote down vote up
private SolrQueryRequest request(ModifiableSolrParams params) {
  SolrCore core = h.getCore();
  SolrRequestHandler handler = core.getRequestHandler(CENTROID_REQUEST_HANDLER);

  SolrQueryResponse rsp = new SolrQueryResponse();
  NamedList<Object> list = new NamedList<Object>();
  list.add("responseHeader", new SimpleOrderedMap<Object>());
  rsp.setAllValues(list);
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  return req;
}
 
Example 7
Source File: QuerySegmenterQParserTest.java    From query-segmenter with Apache License 2.0 5 votes vote down vote up
private SolrQueryRequest request(ModifiableSolrParams params, String handlerName) {
  SolrCore core = h.getCore();
  SolrRequestHandler handler = core.getRequestHandler(handlerName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  NamedList<Object> list = new NamedList<Object>();
  list.add("responseHeader", new SimpleOrderedMap<Object>());
  rsp.setAllValues(list);
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  return req;
}
 
Example 8
Source File: QuerySegmenterComponentTest.java    From query-segmenter with Apache License 2.0 5 votes vote down vote up
private SolrQueryRequest request(ModifiableSolrParams params, String handlerName) {
  SolrCore core = h.getCore();
  SolrRequestHandler handler = core.getRequestHandler(handlerName);

  SolrQueryResponse rsp = new SolrQueryResponse();
  NamedList<Object> list = new NamedList<Object>();
  list.add("responseHeader", new SimpleOrderedMap<Object>());
  rsp.setAllValues(list);
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  return req;
}
 
Example 9
Source File: TestInitParams.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testArbitraryAttributes() {
  SolrRequestHandler handler = h.getCore().getRequestHandler("/dump7");
  SolrQueryResponse rsp = new SolrQueryResponse();
  handler.handleRequest(req("initArgs", "true"), rsp);
  @SuppressWarnings({"rawtypes"})
  NamedList nl = (NamedList) rsp.getValues().get("initArgs");
  assertEquals("server-enabled.txt", nl.get("healthcheckFile"));
}
 
Example 10
Source File: TestInitParams.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testElevateExample(){
  SolrRequestHandler handler = h.getCore().getRequestHandler("/elevate");
  SolrQueryResponse rsp = new SolrQueryResponse();
  handler.handleRequest(req("initArgs", "true"), rsp);
  @SuppressWarnings({"rawtypes"})
  NamedList nl = (NamedList) rsp.getValues().get("initArgs");
  @SuppressWarnings({"rawtypes"})
  NamedList def = (NamedList) nl.get(PluginInfo.DEFAULTS);
  assertEquals("text" ,def.get("df"));

}
 
Example 11
Source File: SpellCheckCollatorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testWithCursorMark() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);
  
  ModifiableSolrParams params = new ModifiableSolrParams();   
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
  params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");   
  params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "2");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1");
  params.add(CommonParams.Q, "lowerfilt:(+fauth)");
  params.add(CommonParams.SORT, "id asc");
  params.add(CursorMarkParams.CURSOR_MARK_PARAM, CursorMarkParams.CURSOR_MARK_START);
  SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.addResponseHeader(new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList collationList = (NamedList) spellCheck.get("collations");
  List<?> collations = (List<?>) collationList.getAll("collation");
  assertTrue(collations.size() == 1);
}
 
Example 12
Source File: SpellCheckCollatorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testZeroTries() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);
  
  ModifiableSolrParams params = new ModifiableSolrParams();   
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
  params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");   
  params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2");
  params.add(CommonParams.Q, "lowerfilt:(+fauth)");
  SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.addResponseHeader(new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList collationList = (NamedList) spellCheck.get("collations");
  List<?> collations = (List<?>) collationList.getAll("collation");
  assertTrue(collations.size() == 2);
}
 
Example 13
Source File: SpellCheckCollatorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testCollateWithGrouping() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellingParams.SPELLCHECK_BUILD, "true");
  params.add(SpellingParams.SPELLCHECK_COUNT, "10");
  params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "5");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1");
  params.add(CommonParams.Q, "lowerfilt:(+fauth)");
  params.add(GroupParams.GROUP, "true");
  params.add(GroupParams.GROUP_FIELD, "id");

  //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
  //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
  SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.addResponseHeader(new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList collationHolder = (NamedList) spellCheck.get("collations");
  List<String> collations = collationHolder.getAll("collation");
  assertTrue(collations.size() == 1);
}
 
Example 14
Source File: SpellCheckCollatorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testCollateWithFilter() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellingParams.SPELLCHECK_BUILD, "true");
  params.add(SpellingParams.SPELLCHECK_COUNT, "10");
  params.add(SpellingParams.SPELLCHECK_COLLATE, "true");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10");
  params.add(SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10");
  params.add(CommonParams.Q, "lowerfilt:(+fauth +home +loane)");
  params.add(CommonParams.FQ, "NOT(id:1)");

  //Because a FilterQuery is applied which removes doc id#1 from possible hits, we would
  //not want the collations to return us "lowerfilt:(+faith +hope +loaves)" as this only matches doc id#1.
  SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.addResponseHeader(new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList collationHolder = (NamedList) spellCheck.get("collations");
  List<String> collations = collationHolder.getAll("collation");
  assertTrue(collations.size() > 0);
  for(String collation : collations) {
    assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)"));
  }
}
 
Example 15
Source File: SpellCheckCollatorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testCollationWithRangeQuery() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);
  
  ModifiableSolrParams params = new ModifiableSolrParams();   
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellingParams.SPELLCHECK_BUILD, "true");
  params.add(SpellingParams.SPELLCHECK_COUNT, "10");   
  params.add(SpellingParams.SPELLCHECK_COLLATE, "true"); 
  params.add(SpellingParams.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "10"); 
  params.add(CommonParams.Q, "id:[1 TO 10] AND lowerfilt:lovw");
  {
    SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH");
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.addResponseHeader(new SimpleOrderedMap());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
    handler.handleRequest(req, rsp);
    req.close();
    NamedList values = rsp.getValues();
    NamedList spellCheck = (NamedList) values.get("spellcheck");
    NamedList collationHolder = (NamedList) spellCheck.get("collations");
    List<String> collations = collationHolder.getAll("collation");
    assertTrue(collations.size()==1); 
    String collation = collations.iterator().next();    
    System.out.println(collation);
    assertTrue("Incorrect collation: " + collation,"id:[1 TO 10] AND lowerfilt:love".equals(collation));
  }
}
 
Example 16
Source File: SolrInformationServer.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private SolrDocumentList executeQueryRequest(SolrQueryRequest request, SolrQueryResponse response, SolrRequestHandler handler)
{
    handler.handleRequest(request, response);

    NamedList<?> values = response.getValues();
    return (SolrDocumentList) values.get(RESPONSE_DEFAULT_IDS);
}
 
Example 17
Source File: SimpleTreeFacetComponentTest.java    From BioSolr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testResultsWithOtherFacets() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "name:nodeA*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "{!ftree childField=child_ids}node_id");
	params.add("facet.field", "label");
	params.add("facet.field", "node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNull(rsp.getException());
    
    NamedList results = rsp.getValues();
    
    NamedList facetFields = (NamedList)((NamedList)(results.get("facet_counts"))).get("facet_fields");
    assertNotNull(facetFields);
    assertNotNull(facetFields.get("label"));
    assertNotNull(facetFields.get("node_id"));
    
    NamedList facetTree = (NamedList) ((NamedList)(results.get("facet_counts"))).get("facet_trees");
    assertNotNull(facetTree);
    
    // Check the generated hierarchy - should be three levels deep
    List<Object> nodes = (List) facetTree.get("node_id");
    assertEquals(1, nodes.size());
    NamedList level1 = (NamedList) nodes.get(0);
    assertEquals("A", level1.get("value"));
    assertEquals(1L, level1.get("count"));
    assertEquals(6L, level1.get("total"));
    List level2Nodes = (List)level1.get("hierarchy");
    assertEquals(3, level2Nodes.size());
    NamedList level2 = (NamedList)level2Nodes.get(0);
    assertEquals(1L, level2.get("count"));
    assertEquals(3L, level2.get("total"));
    List level3Nodes = (List)level2.get("hierarchy");
    assertEquals(2, level3Nodes.size());
    NamedList level3 = (NamedList)level3Nodes.get(0);
    assertEquals(1L, level3.get("count"));
    assertEquals(1L, level3.get("total"));
    assertNull(level3.get("hierarchy"));
}
 
Example 18
Source File: SolrCore.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
  if (handler == null) {
    String msg = "Null Request Handler '" +
        req.getParams().get(CommonParams.QT) + "'";

    log.warn("{}{}:{}", logid, msg, req);

    throw new SolrException(ErrorCode.BAD_REQUEST, msg);
  }

  preDecorateResponse(req, rsp);

  /*
   * Keeping this usage of isDebugEnabled because the extraction of the log data as a string might be slow. TODO:
   * Determine how likely it is that something is going to go wrong that will prevent the logging at INFO further
   * down, and if possible, prevent that situation. The handleRequest and postDecorateResponse methods do not indicate
   * that they throw any checked exceptions, so it would have to be an unchecked exception that causes any problems.
   */
  if (requestLog.isDebugEnabled() && rsp.getToLog().size() > 0) {
    // log request at debug in case something goes wrong and we aren't able to log later
    requestLog.debug(rsp.getToLogAsString(logid));
  }

  // TODO: this doesn't seem to be working correctly and causes problems with the example server and distrib (for example /spell)
  // if (req.getParams().getBool(ShardParams.IS_SHARD,false) && !(handler instanceof SearchHandler))
  //   throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"isShard is only acceptable with search handlers");

  handler.handleRequest(req, rsp);
  postDecorateResponse(handler, req, rsp);

  if (rsp.getToLog().size() > 0) {
    if (requestLog.isInfoEnabled()) {
      requestLog.info(rsp.getToLogAsString(logid));
    }

    /* slowQueryThresholdMillis defaults to -1 in SolrConfig -- not enabled.*/
    if (log.isWarnEnabled() && slowQueryThresholdMillis >= 0) {
      final long qtime = (long) (req.getRequestTimer().getTime());
      if (qtime >= slowQueryThresholdMillis) {
        slowLog.warn("slow: {}", rsp.getToLogAsString(logid));
      }
    }
  }
}
 
Example 19
Source File: SimpleTreeFacetComponentTest.java    From BioSolr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testSingleResult() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "name:nodeAAA");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "{!ftree childField=child_ids}node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNull(rsp.getException());
    
    NamedList results = rsp.getValues();
    NamedList facetTree = (NamedList) ((NamedList)(results.get("facet_counts"))).get("facet_trees");
    assertNotNull(facetTree);
    
    // Check the generated hierarchy - should be three levels deep
    List<Object> nodes = (List) facetTree.get("node_id");
    assertEquals(1, nodes.size());
    NamedList level1 = (NamedList) nodes.get(0);
    assertEquals("A", level1.get("value"));
    assertEquals(0L, level1.get("count"));
    assertEquals(1L, level1.get("total"));
    List level2Nodes = (List)level1.get("hierarchy");
    NamedList level2 = (NamedList)level2Nodes.get(0);
    assertEquals("AA", level2.get("value"));
    assertEquals(0L, level2.get("count"));
    assertEquals(1L, level2.get("total"));
    List level3Nodes = (List)level2.get("hierarchy");
    NamedList level3 = (NamedList)level3Nodes.get(0);
    assertEquals("AAA", level3.get("value"));
    assertEquals(1L, level3.get("count"));
    assertEquals(1L, level3.get("total"));
    assertNull(level3.get("hierarchy"));
}
 
Example 20
Source File: SimpleTreeFacetComponentTest.java    From BioSolr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testMultipleResults() {
	SolrCore core = h.getCore();
	
	ModifiableSolrParams params = new ModifiableSolrParams();
	params.add("q", "name:nodeA*");
	params.add("facet", "true");
	params.add("facet.tree", "true");
	params.add("facet.tree.field", "{!ftree childField=child_ids}node_id");
	
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap<>());
    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);

    SolrRequestHandler handler = core.getRequestHandler(requestHandler);
    handler.handleRequest(req, rsp);
    req.close();
      
    assertNull(rsp.getException());
    
    NamedList results = rsp.getValues();
    NamedList facetTree = (NamedList) ((NamedList)(results.get("facet_counts"))).get("facet_trees");
    assertNotNull(facetTree);
    
    // Check the generated hierarchy - should be three levels deep
    List<Object> nodes = (List) facetTree.get("node_id");
    assertEquals(1, nodes.size());
    NamedList level1 = (NamedList) nodes.get(0);
    assertEquals("A", level1.get("value"));
    assertEquals(1L, level1.get("count"));
    assertEquals(6L, level1.get("total"));
    List level2Nodes = (List)level1.get("hierarchy");
    assertEquals(3, level2Nodes.size());
    NamedList level2 = (NamedList)level2Nodes.get(0);
    assertEquals(1L, level2.get("count"));
    assertEquals(3L, level2.get("total"));
    List level3Nodes = (List)level2.get("hierarchy");
    assertEquals(2, level3Nodes.size());
    NamedList level3 = (NamedList)level3Nodes.get(0);
    assertEquals(1L, level3.get("count"));
    assertEquals(1L, level3.get("total"));
    assertNull(level3.get("hierarchy"));
}