本文整理汇总了Java中org.apache.lucene.search.join.ScoreMode.Max方法的典型用法代码示例。如果您正苦于以下问题:Java ScoreMode.Max方法的具体用法?Java ScoreMode.Max怎么用?Java ScoreMode.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.join.ScoreMode
的用法示例。
在下文中一共展示了ScoreMode.Max方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseScoreMode
import org.apache.lucene.search.join.ScoreMode; //导入方法依赖的package包/类
public static ScoreMode parseScoreMode(String scoreModeString) {
if ("none".equals(scoreModeString)) {
return ScoreMode.None;
} else if ("min".equals(scoreModeString)) {
return ScoreMode.Min;
} else if ("max".equals(scoreModeString)) {
return ScoreMode.Max;
} else if ("avg".equals(scoreModeString)) {
return ScoreMode.Avg;
} else if ("sum".equals(scoreModeString)) {
return ScoreMode.Total;
}
throw new IllegalArgumentException("No score mode for child query [" + scoreModeString + "] found");
}
示例2: parse
import org.apache.lucene.search.join.ScoreMode; //导入方法依赖的package包/类
@Override
public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException {
XContentParser parser = parseContext.parser();
final ToBlockJoinQueryBuilder builder = new ToBlockJoinQueryBuilder(parseContext);
float boost = 1.0f;
ScoreMode scoreMode = ScoreMode.Avg;
String queryName = null;
String currentFieldName = null;
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if ("query".equals(currentFieldName)) {
builder.query();
} else if (parseContext.parseFieldMatcher().match(currentFieldName, FILTER_FIELD)) {
builder.filter();
} else if ("inner_hits".equals(currentFieldName)) {
builder.setInnerHits(innerHitsQueryParserHelper.parse(parseContext));
} else {
throw new QueryParsingException(parseContext, "[nested] query does not support [" + currentFieldName + "]");
}
} else if (token.isValue()) {
if ("path".equals(currentFieldName)) {
builder.setPath(parser.text());
} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else if ("score_mode".equals(currentFieldName) || "scoreMode".equals(currentFieldName)) {
String sScoreMode = parser.text();
if ("avg".equals(sScoreMode)) {
scoreMode = ScoreMode.Avg;
} else if ("min".equals(sScoreMode)) {
scoreMode = ScoreMode.Min;
} else if ("max".equals(sScoreMode)) {
scoreMode = ScoreMode.Max;
} else if ("total".equals(sScoreMode) || "sum".equals(sScoreMode)) {
scoreMode = ScoreMode.Total;
} else if ("none".equals(sScoreMode)) {
scoreMode = ScoreMode.None;
} else {
throw new QueryParsingException(parseContext, "illegal score_mode for nested query [" + sScoreMode + "]");
}
} else if ("_name".equals(currentFieldName)) {
queryName = parser.text();
} else {
throw new QueryParsingException(parseContext, "[nested] query does not support [" + currentFieldName + "]");
}
}
}
builder.setScoreMode(scoreMode);
ToParentBlockJoinQuery joinQuery = builder.build();
if (joinQuery != null) {
joinQuery.setBoost(boost);
if (queryName != null) {
parseContext.addNamedQuery(queryName, joinQuery);
}
}
return joinQuery;
}
示例3: joinUtilHelper
import org.apache.lucene.search.join.ScoreMode; //导入方法依赖的package包/类
public static Query joinUtilHelper(String parentType, ParentChildIndexFieldData parentChildIndexFieldData, Similarity similarity, Query toQuery, ScoreType scoreType, Query innerQuery, int minChildren, int maxChildren) throws IOException {
ScoreMode scoreMode;
// TODO: move entirely over from ScoreType to org.apache.lucene.join.ScoreMode, when we drop the 1.x parent child code.
switch (scoreType) {
case NONE:
scoreMode = ScoreMode.None;
break;
case MIN:
scoreMode = ScoreMode.Min;
break;
case MAX:
scoreMode = ScoreMode.Max;
break;
case SUM:
scoreMode = ScoreMode.Total;
break;
case AVG:
scoreMode = ScoreMode.Avg;
break;
default:
throw new UnsupportedOperationException("score type [" + scoreType + "] not supported");
}
// 0 in pre 2.x p/c impl means unbounded
if (maxChildren == 0) {
maxChildren = Integer.MAX_VALUE;
}
return new LateParsingQuery(toQuery, innerQuery, minChildren, maxChildren, parentType, scoreMode, parentChildIndexFieldData, similarity);
}