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


Java SolrPluginUtils.DisjunctionMaxQueryParser方法代码示例

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


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

示例1: getUserQuery

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
protected Query getUserQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser up, SolrParams solrParams)
        throws SyntaxError {


  String minShouldMatch = parseMinShouldMatch(req.getSchema(), solrParams);
  Query dis = up.parse(userQuery);
  Query query = dis;

  if (dis instanceof BooleanQuery) {
    BooleanQuery t = new BooleanQuery();
    SolrPluginUtils.flattenBooleanQuery(t, (BooleanQuery) dis);
    SolrPluginUtils.setMinShouldMatch(t, minShouldMatch);
    query = t;
  }
  return query;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:DisMaxQParser.java

示例2: addMainQuery

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
/** Adds the main query to the query argument. If its blank then false is returned. */
protected boolean addMainQuery(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
  Map<String, Float> phraseFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.PF));
  float tiebreaker = solrParams.getFloat(DisMaxParams.TIE, 0.0f);

  /* a parser for dealing with user input, which will convert
   * things to DisjunctionMaxQueries
   */
  SolrPluginUtils.DisjunctionMaxQueryParser up = getParser(queryFields, DisMaxParams.QS, solrParams, tiebreaker);

  /* for parsing sloppy phrases using DisjunctionMaxQueries */
  SolrPluginUtils.DisjunctionMaxQueryParser pp = getParser(phraseFields, DisMaxParams.PS, solrParams, tiebreaker);

  /* * * Main User Query * * */
  parsedUserQuery = null;
  String userQuery = getString();
  altUserQuery = null;
  if (userQuery == null || userQuery.trim().length() < 1) {
    // If no query is specified, we may have an alternate
    altUserQuery = getAlternateUserQuery(solrParams);
    if (altUserQuery == null)
      return false;
    query.add(altUserQuery, BooleanClause.Occur.MUST);
  } else {
    // There is a valid query string
    userQuery = SolrPluginUtils.partialEscape(SolrPluginUtils.stripUnbalancedQuotes(userQuery)).toString();
    userQuery = SolrPluginUtils.stripIllegalOperators(userQuery).toString();

    parsedUserQuery = getUserQuery(userQuery, up, solrParams);
    query.add(parsedUserQuery, BooleanClause.Occur.MUST);

    Query phrase = getPhraseQuery(userQuery, pp);
    if (null != phrase) {
      query.add(phrase, BooleanClause.Occur.SHOULD);
    }
  }
  return true;
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:DisMaxQParser.java

示例3: getPhraseQuery

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
protected Query getPhraseQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser pp) throws SyntaxError {
  /* * * Add on Phrases for the Query * * */

  /* build up phrase boosting queries */

  /* if the userQuery already has some quotes, strip them out.
   * we've already done the phrases they asked for in the main
   * part of the query, this is to boost docs that may not have
   * matched those phrases but do match looser phrases.
  */
  String userPhraseQuery = userQuery.replace("\"", "");
  return pp.parse("\"" + userPhraseQuery + "\"");
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:DisMaxQParser.java

示例4: getParser

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
protected SolrPluginUtils.DisjunctionMaxQueryParser getParser(Map<String, Float> fields, String paramName,
                                                              SolrParams solrParams, float tiebreaker) {
  int slop = solrParams.getInt(paramName, 0);
  SolrPluginUtils.DisjunctionMaxQueryParser parser = new SolrPluginUtils.DisjunctionMaxQueryParser(this,
          IMPOSSIBLE_FIELD_NAME);
  parser.addAlias(IMPOSSIBLE_FIELD_NAME, tiebreaker, fields);
  parser.setPhraseSlop(slop);
  return parser;
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:DisMaxQParser.java


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