本文整理汇总了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;
}
示例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;
}
示例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 + "\"");
}
示例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;
}