当前位置: 首页>>代码示例>>Java>>正文


Java ResponseBuilder.getQueryString方法代码示例

本文整理汇总了Java中org.apache.solr.handler.component.ResponseBuilder.getQueryString方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseBuilder.getQueryString方法的具体用法?Java ResponseBuilder.getQueryString怎么用?Java ResponseBuilder.getQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.handler.component.ResponseBuilder的用法示例。


在下文中一共展示了ResponseBuilder.getQueryString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSuggestions

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private Set<String> createSuggestions(ResponseBuilder rb, NamedList suggestions,
    SuggestionsFoundRatioCalculator ratioCalc, int spellcheckCount, long originalQueryHits, Float highestRatio) {
  SuggestionRatioProcessor ratioCalcProcessor = new SuggestionRatioProcessor(originalQueryHits, spellcheckCount,
      ratioCalc, highestRatio);
  ReSearcherUtils.iterateOverSpellcheckerSuggestionsForAllIncorrectWords(suggestions, ratioCalcProcessor);

  Set<String> newSuggestions = null;

  if (ratioCalcProcessor.getSuggestionWithHighestRatio() != null) {
    CreateNewSuggestionsProcessor newSuggestionsProcessor = new CreateNewSuggestionsProcessor(rb.getQueryString(),
        ratioCalcProcessor.getSuggestionWithHighestRatio());
    ReSearcherUtils.iterateOverSpellcheckerSuggestionsForWord(ratioCalcProcessor.getSuggestionWithHighestRatio(),
        newSuggestionsProcessor);
    newSuggestions = newSuggestionsProcessor.getNewSuggestions();
  }

  if (ignoreCollation == false) {
    //newSuggestions.add((String) suggestions.get("collation"));
      if (rb.rsp.getValues().get("spellcheck") != null) {
          if (((SimpleOrderedMap) rb.rsp.getValues().get("spellcheck")).get("collations") != null) {
              newSuggestions.add((String) (((NamedList) ((SimpleOrderedMap) rb.rsp.getValues().get("spellcheck")).get("collations")).get("collation")));
          }
      }
  }

  return newSuggestions;
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:29,代码来源:DymReSearcher.java

示例2: ReSearcherRequestContext

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
public ReSearcherRequestContext(ResponseBuilder rb) {
  params = new ModifiableSolrParams(rb.req.getParams());
  originalQueryString = rb.getQueryString();
  originalQueryHits = ReSearcherUtils.extractOriginalQueryHits(rb);
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:6,代码来源:ReSearcherRequestContext.java

示例3: preProcessOriginalQuery

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
public boolean preProcessOriginalQuery(ReSearcherRequestContext ctx, ResponseBuilder rb) {
  if (commonMisspellingsFileLocation == null) {
    return false;
  }

  String originalQuery = rb.getQueryString();
  String correctedQuery = CommonMisspellings.correctedQuery(originalQuery, commonMisspellingsMap);
  if (correctedQuery != null) {
    LOG.info("Original query : '" + originalQuery + "' is corrected to '" + correctedQuery
        + "', checking its results...");
    ctx.setCorrectedQuery(correctedQuery);

    try {
      long hits = ctx.getHandler().handleSuggestionHitsRequest(ctx, correctedQuery, componentNames);
      LOG.info("New query : '" + correctedQuery + "' produced " + hits + " hits");

      if (hits > maxOriginalResults) {
        ctx.setCorrectedQueryHits(hits);
        List<String> suggestionsList = new ArrayList<String>();
        suggestionsList.add(correctedQuery);
        Map<String, Long> suggestionsHitCounts = new HashMap<String, Long>();
        suggestionsHitCounts.put(correctedQuery, hits);
        ReSearcherUtils.addValueToResult(rb, getSuggestionsTagName(), suggestionsList);
        ReSearcherUtils.addValueToResult(rb, getSuggestionsTagName() + "_hit_counts", suggestionsHitCounts);
        
        SolrQueryResponse rsp = ctx.getHandler().handleSuggestionResponseRequest(ctx, correctedQuery, getComponentName(), rb);
        rb.rsp.add("spellchecked_response", rsp.getValues().get("response"));
        rb.rsp.add("spellchecked_facet_counts", rsp.getValues().get("facet_counts"));
        rb.rsp.add("spellchecked_terms", rsp.getValues().get("terms"));
        rb.rsp.add("spellchecked_termVectors", rsp.getValues().get("termVectors"));
        rb.rsp.add("spellchecked_highlighting", rsp.getValues().get("highlighting"));
        rb.rsp.add("spellchecked_stats", rsp.getValues().get("stats"));
        rb.rsp.add("spellchecked_grouped", rsp.getValues().get("grouped"));
        return true;
      }
    } catch (Exception e) {
      String msg = "Error while correcting original query '" + originalQuery + "' to query '" + correctedQuery
          + "' and searching for results!";
      LOG.error(msg, e);
      throw new RuntimeException(msg, e);
    }
  }

  return false;
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:46,代码来源:AbstractReSearcherComponent.java

示例4: process

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
/** 
 * Responsible for using the specified suggester to get the suggestions 
 * for the query and write the results 
 * */
@Override
public void process(ResponseBuilder rb) throws IOException {
  SolrParams params = rb.req.getParams();
  LOG.debug("SuggestComponent process with : " + params);
  if (!params.getBool(COMPONENT_NAME, false) || suggesters.isEmpty()) {
    return;
  }
  
  boolean buildAll = params.getBool(SUGGEST_BUILD_ALL, false);
  boolean reloadAll = params.getBool(SUGGEST_RELOAD_ALL, false);
  Set<AlfrescoSolrSuggester> querySuggesters;
  try {
    querySuggesters = getSuggesters(params);
  } catch(IllegalArgumentException ex) {
    if (!buildAll && !reloadAll) {
      throw ex;
    } else {
      querySuggesters = new HashSet<>();
    }
  }
  
  String query = params.get(SUGGEST_Q);
  if (query == null) {
    query = rb.getQueryString();
    if (query == null) {
      query = params.get(CommonParams.Q);
    }
  }
  
  if (query != null) {
    int count = params.getInt(SUGGEST_COUNT, 1);
    SuggesterOptions options = new SuggesterOptions(new CharsRef(query), count);
    Map<String, SimpleOrderedMap<NamedList<Object>>> namedListResults = 
        new HashMap<>();
    for (AlfrescoSolrSuggester suggester : querySuggesters) {
      SuggesterResult suggesterResult = suggester.getSuggestions(options);
      toNamedList(suggesterResult, namedListResults);
    }
    rb.rsp.add(SuggesterResultLabels.SUGGEST, namedListResults);
  }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:46,代码来源:AsyncBuildSuggestComponent.java

示例5: prepare

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
/**
 * Add boost terms to the query if it matches a know query.
 *
 * The query string is analyzed and compared to the known query strings
 * from the XML file. If a matching (i.e. equal) query string is found,
 * the associated terms (ConstantScoreQuery) are added: the original
 * query (object, not string) is added as a MUST term in a newly created
 * BooleanQuery, whereas the new terms are added either as Occur.SHOULD
 * for positive boost, or Occur.MUST_NOT for zero or negative boost.
 *
 * prepare() might trigger a reload of the XML file if it resides in
 * the data/ directory and the reader is new.
 *
 */
@Override
public final void prepare(final ResponseBuilder rb) {
    if (disabled(rb)) {
        return;
    }
    Query query = rb.getQuery();
    String queryStr = rb.getQueryString();
    if (query == null || queryStr == null) {
        return;
    }
    IndexReader reader = rb.req.getSearcher().getIndexReader();
    List<Query> boostTerms = null;
    try {
        queryStr = getAnalyzedQuery(queryStr);
        boostTerms = getQLTBMap(reader, rb.req.getCore()).get(queryStr);
        if (boostTerms == null || boostTerms.isEmpty()) {
            return;
        }
        log.debug(
            "QLTBComponent.prepare() query: \"" + queryStr + "\" with "
            + boostTerms.size() + " boost terms"
        );
    } catch (Exception ex) {
        throw new SolrException(
            SolrException.ErrorCode.SERVER_ERROR,
            "error loading QLTB",
            ex
        );
    }
    BooleanQuery newq = new BooleanQuery(true);
    newq.add(query, BooleanClause.Occur.MUST);
    for (Query term : boostTerms) {
        if (term.getBoost() > 0.0) {
            newq.add(new BooleanClause(term, BooleanClause.Occur.SHOULD));
        } else {
            newq.add(new BooleanClause(term, BooleanClause.Occur.MUST_NOT));
        }
    }
    rb.setQuery(newq);
}
 
开发者ID:solute,项目名称:qltb,代码行数:55,代码来源:QLTBComponent.java


注:本文中的org.apache.solr.handler.component.ResponseBuilder.getQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。