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


Java StandardQueryParser.setAllowLeadingWildcard方法代码示例

本文整理汇总了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();
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:24,代码来源:ElasticSearchUtils.java

示例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");
}
 
开发者ID:Tietoarkisto,项目名称:metka,代码行数:23,代码来源:ExpertRevisionSearchCommand.java

示例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;
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:14,代码来源:ElasticSearchUtils.java


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