本文整理汇总了Java中org.apache.lucene.queryparser.classic.QueryParser.setLowercaseExpandedTerms方法的典型用法代码示例。如果您正苦于以下问题:Java QueryParser.setLowercaseExpandedTerms方法的具体用法?Java QueryParser.setLowercaseExpandedTerms怎么用?Java QueryParser.setLowercaseExpandedTerms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queryparser.classic.QueryParser
的用法示例。
在下文中一共展示了QueryParser.setLowercaseExpandedTerms方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import org.apache.lucene.queryparser.classic.QueryParser; //导入方法依赖的package包/类
Query query( String keyOrNull, Object value, QueryContext contextOrNull )
{
if ( value instanceof Query )
{
return (Query) value;
}
QueryParser parser = new QueryParser( keyOrNull, analyzer );
parser.setAllowLeadingWildcard( true );
parser.setLowercaseExpandedTerms( toLowerCase );
if ( contextOrNull != null && contextOrNull.getDefaultOperator() != null )
{
parser.setDefaultOperator( contextOrNull.getDefaultOperator() );
}
try
{
return parser.parse( value.toString() );
}
catch ( ParseException e )
{
throw new RuntimeException( e );
}
}
示例2: query
import org.apache.lucene.queryparser.classic.QueryParser; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public Query query(Schema schema) {
if (query == null) {
throw new IllegalArgumentException("Query statement required");
}
try {
Analyzer analyzer = schema.getAnalyzer();
QueryParser queryParser = new QueryParser(defaultField, analyzer);
queryParser.setAllowLeadingWildcard(true);
queryParser.setLowercaseExpandedTerms(false);
Query luceneQuery = queryParser.parse(query);
luceneQuery.setBoost(boost);
return luceneQuery;
} catch (ParseException e) {
throw new RuntimeException("Error while parsing lucene syntax query", e);
}
}
示例3: create
import org.apache.lucene.queryparser.classic.QueryParser; //导入方法依赖的package包/类
private QueryExpression create(Request request, ResourceDefinition resourceDefinition) throws InvalidQueryException {
String queryString;
if (request.getCardinality() == Request.Cardinality.INSTANCE) {
String idPropertyName = resourceDefinition.getIdPropertyName();
queryString = String.format("%s:%s", idPropertyName, request.<String>getProperty(idPropertyName));
} else {
queryString = request.getQueryString();
}
QueryExpression queryExpression;
if (queryString != null && !queryString.isEmpty()) {
QueryParser queryParser = new QueryParser(Version.LUCENE_48, "name", new KeywordAnalyzer());
queryParser.setLowercaseExpandedTerms(false);
queryParser.setAllowLeadingWildcard(true);
Query query;
try {
query = queryParser.parse((String) escape(queryString));
} catch (ParseException e) {
throw new InvalidQueryException(e.getMessage());
}
LOG.info("LuceneQuery: {}", query);
queryExpression = create(query, resourceDefinition);
} else {
queryExpression = new AlwaysQueryExpression();
}
// add query properties to request so that they are returned
request.addAdditionalSelectProperties(queryExpression.getProperties());
return queryExpression;
}
示例4: buildQueryFromText
import org.apache.lucene.queryparser.classic.QueryParser; //导入方法依赖的package包/类
private static Query buildQueryFromText(String field, IndexSchema schema, String query) {
QueryParser queryParser = new QueryParser(Version.LUCENE_45, field, schema.getQueryAnalyzer());
queryParser.setAllowLeadingWildcard(false);
queryParser.setLowercaseExpandedTerms(false);
queryParser.setTimeZone(TimeZone.getDefault());
queryParser.setAnalyzeRangeTerms(true);
try {
return queryParser.parse(query);
} catch (org.apache.lucene.queryparser.classic.ParseException e) {
throw new RuntimeException(e);
}
}