本文整理汇总了Java中org.apache.lucene.queryparser.flexible.standard.StandardQueryParser.setAllowLeadingWildcard方法的典型用法代码示例。如果您正苦于以下问题:Java StandardQueryParser.setAllowLeadingWildcard方法的具体用法?Java StandardQueryParser.setAllowLeadingWildcard怎么用?Java StandardQueryParser.setAllowLeadingWildcard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queryparser.flexible.standard.StandardQueryParser
的用法示例。
在下文中一共展示了StandardQueryParser.setAllowLeadingWildcard方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: qs
import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser; //导入方法依赖的package包/类
/**
* Tries to parse a query string in order to check if it is valid.
* @param query a Lucene query string
* @return the query if valid, or '*' if invalid
*/
static String qs(String query) {
if (StringUtils.isBlank(query) || "*".equals(query.trim())) {
return "*";
}
query = query.trim();
if (query.length() > 1 && query.startsWith("*")) {
query = query.substring(1);
}
try {
StandardQueryParser parser = new StandardQueryParser();
parser.setAllowLeadingWildcard(false);
parser.parse(query, "");
} catch (Exception ex) {
logger.warn("Failed to parse query string '{}'.", query);
query = "*";
}
return query.trim();
}
示例2: ExpertRevisionSearchCommand
import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser; //导入方法依赖的package包/类
private ExpertRevisionSearchCommand(DirectoryManager.DirectoryPath path, String qry, Configuration configuration)
throws QueryNodeException {
super(path, ResultList.ResultType.REVISION);
setLanguage(extractLanguage(qry));
Map<String, NumericConfig> nums = new HashMap<>();
/*StandardQueryParser parser = new StandardQueryParser(getAnalyzer());*/
StandardQueryParser parser = new StandardQueryParser();
parser.setAllowLeadingWildcard(true);
parser.setAnalyzer(getAnalyzer());
if(!StringUtils.hasText(qry)) {
throw new ParseException(new MessageImpl("EMPTY_QUERY"));
}
query = parser.parse(qry, "general");
// No matter if we have configuraion or not we'll parse the query twice. This second parsing will add analyzers for known keys like key.id
// as well as fields found from configuration if configuration is provided
addAnalyzersAndConfigs(query, nums, configuration);
parser.setAnalyzer(getAnalyzer());
parser.setNumericConfigMap(nums);
query = parser.parse(qry, "general");
}
示例3: qsParsed
import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser; //导入方法依赖的package包/类
static Query qsParsed(String query) {
if (StringUtils.isBlank(query) || "*".equals(query.trim())) {
return null;
}
try {
StandardQueryParser parser = new StandardQueryParser();
parser.setAllowLeadingWildcard(false);
return parser.parse(query, "");
} catch (Exception ex) {
logger.warn("Failed to parse query string '{}'.", query);
}
return null;
}