本文整理汇总了Java中org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler.getFieldConfig方法的典型用法代码示例。如果您正苦于以下问题:Java QueryConfigHandler.getFieldConfig方法的具体用法?Java QueryConfigHandler.getFieldConfig怎么用?Java QueryConfigHandler.getFieldConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler
的用法示例。
在下文中一共展示了QueryConfigHandler.getFieldConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessNode
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入方法依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
if (node instanceof FieldQueryNode
&& !(node.getParent() instanceof RangeQueryNode)) {
QueryConfigHandler config = getQueryConfigHandler();
if (config != null) {
FieldQueryNode fieldNode = (FieldQueryNode) node;
FieldConfig fieldConfig = config.getFieldConfig(fieldNode
.getFieldAsString());
if (fieldConfig != null) {
NumericConfig numericConfig = fieldConfig
.get(ConfigurationKeys.NUMERIC_CONFIG);
if (numericConfig != null) {
NumberFormat numberFormat = numericConfig.getNumberFormat();
String text = fieldNode.getTextAsString();
Number number = null;
if (text.length() > 0) {
try {
number = numberFormat.parse(text);
} catch (ParseException e) {
throw new QueryNodeParseException(new MessageImpl(
QueryParserMessages.COULD_NOT_PARSE_NUMBER, fieldNode
.getTextAsString(), numberFormat.getClass()
.getCanonicalName()), e);
}
switch (numericConfig.getType()) {
case LONG:
number = number.longValue();
break;
case INT:
number = number.intValue();
break;
case DOUBLE:
number = number.doubleValue();
break;
case FLOAT:
number = number.floatValue();
}
} else {
throw new QueryNodeParseException(new MessageImpl(
QueryParserMessages.NUMERIC_CANNOT_BE_EMPTY, fieldNode.getFieldAsString()));
}
NumericQueryNode lowerNode = new NumericQueryNode(fieldNode
.getField(), number, numberFormat);
NumericQueryNode upperNode = new NumericQueryNode(fieldNode
.getField(), number, numberFormat);
return new NumericRangeQueryNode(lowerNode, upperNode, true, true,
numericConfig);
}
}
}
}
return node;
}
示例2: postProcessNode
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler; //导入方法依赖的package包/类
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
if (node instanceof FieldableNode &&
(node.getParent() == null || !(node.getParent() instanceof FieldableNode))) {
FieldableNode fieldNode = (FieldableNode) node;
QueryConfigHandler config = getQueryConfigHandler();
if (config != null) {
CharSequence field = fieldNode.getField();
FieldConfig fieldConfig = config.getFieldConfig(StringUtils.toString(field));
if (fieldConfig != null) {
Float boost = fieldConfig.get(ConfigurationKeys.BOOST);
if (boost != null) {
return new BoostQueryNode(node, boost);
}
}
}
}
return node;
}