@Override
  public QParser createParser(
      String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
    ModifiableSolrParams customParams = new ModifiableSolrParams();

    if (qstr.contains("#")) {
      CUSTOM_QF[3] = "tweet_hashtags^1.5";
    } else {
      CUSTOM_QF[3] = "tweet_hashtags^0.5";
    }

    if (qstr.contains(LANG_EN)) {
      CUSTOM_QF[0] = "text_en^1.25";
      qstr = qstr.replace(LANG_EN, "");
    }

    if (qstr.contains(LANG_DE)) {
      CUSTOM_QF[1] = "text_de^1.25";
      qstr = qstr.replace(LANG_DE, "");
    }

    if (qstr.contains(LANG_RU)) {
      CUSTOM_QF[2] = "text_ru^1.25";
      qstr = qstr.replace(LANG_RU, "");
    }

    customParams.add(DisMaxParams.QF, CUSTOM_QF);
    params = SolrParams.wrapAppended(params, customParams);
    return new ExtendedDismaxQParser(qstr, localParams, params, req);
  }
  /**
   * Given some query params, executes the request against the cloudClient and then walks the pivot
   * facet values in the response, treating each one as a filter query to assert the pivot counts
   * are correct.
   */
  private void assertPivotCountsAreCorrect(SolrParams baseParams, SolrParams pivotParams)
      throws SolrServerException {

    SolrParams initParams = SolrParams.wrapAppended(pivotParams, baseParams);

    log.info("Doing full run: {}", initParams);
    countNumFoundChecks = 0;

    NamedList<List<PivotField>> pivots = null;
    try {
      QueryResponse initResponse = cloudClient.query(initParams);
      pivots = initResponse.getFacetPivot();
      assertNotNull(initParams + " has null pivots?", pivots);
      assertEquals(
          initParams + " num pivots", initParams.getParams("facet.pivot").length, pivots.size());
    } catch (Exception e) {
      throw new RuntimeException("init query failed: " + initParams + ": " + e.getMessage(), e);
    }
    try {
      for (Map.Entry<String, List<PivotField>> pivot : pivots) {
        final String pivotKey = pivot.getKey();
        // :HACK: for counting the max possible pivot depth
        final int maxDepth = 1 + pivotKey.length() - pivotKey.replace(",", "").length();

        assertTraceOk(pivotKey, baseParams, pivot.getValue());

        // NOTE: we can't make any assumptions/assertions about the number of
        // constraints here because of the random data - which means if pivotting is
        // completely broken and there are no constrains this loop could be a No-Op
        // but in that case we just have to trust that DistributedFacetPivotTest
        // will catch it.
        for (PivotField constraint : pivot.getValue()) {
          int depth = assertPivotCountsAreCorrect(pivotKey, baseParams, constraint);

          // we can't assert that the depth reached is the same as the depth requested
          // because the fq and/or mincount may have pruned the tree too much
          assertTrue(
              "went too deep: " + depth + ": " + pivotKey + " ==> " + pivot, depth <= maxDepth);
        }
      }
    } catch (AssertionError e) {
      throw new AssertionError(initParams + " ==> " + e.getMessage(), e);
    } finally {
      log.info("Ending full run (countNumFoundChecks={}): {}", countNumFoundChecks, initParams);
    }
  }
  /**
   * Recursive Helper method for asserting that pivot constraint counts match results when filtering
   * on those constraints. Returns the recursive depth reached (for sanity checking)
   */
  private int assertPivotCountsAreCorrect(
      String pivotName, SolrParams baseParams, PivotField constraint) throws SolrServerException {

    SolrParams p = SolrParams.wrapAppended(baseParams, params("fq", buildFilter(constraint)));
    List<PivotField> subPivots = null;
    try {
      assertPivotData(pivotName, constraint, p);
      subPivots = constraint.getPivot();
    } catch (Exception e) {
      throw new RuntimeException(
          pivotName + ": count query failed: " + p + ": " + e.getMessage(), e);
    }
    int depth = 0;
    if (null != subPivots) {
      assertTraceOk(pivotName, baseParams, subPivots);

      for (PivotField subPivot : subPivots) {
        depth = assertPivotCountsAreCorrect(pivotName, p, subPivot);
      }
    }
    return depth + 1;
  }