本文整理了Java中org.apache.lucene.queryParser.ParseException.getMessage()
方法的一些代码示例,展示了ParseException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.getMessage()
方法的具体详情如下:
包路径:org.apache.lucene.queryParser.ParseException
类名称:ParseException
方法名:getMessage
[英]This method has the standard behavior when this object has been created using the standard constructors. Otherwise, it uses "currentToken" and "expectedTokenSequences" to generate a parse error message and returns it. If this object has been created due to a parse error, and you do not catch it (it gets thrown from the parser), then this method is called during the printing of the final stack trace, and hence the correct error message gets displayed.
[中]使用标准构造函数创建此对象时,此方法具有标准行为。否则,它将使用“currentToken”和“expectedTokenSequences”生成一条解析错误消息并返回它。如果此对象是由于解析错误创建的,而您没有捕获它(它会从解析器中抛出),那么在打印最终堆栈跟踪期间会调用此方法,因此会显示正确的错误消息。
代码示例来源:origin: org.cytoscape/search-impl
@Override
public void run() {
JOptionPane.showMessageDialog(null, pe.getMessage(), "Invalid query.", JOptionPane.ERROR_MESSAGE);
}
});
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* This method handles known lucene errors into user-friendly error message.
*/
@Nullable
private String translateException(final Exception ex, final I18nHelper i18n, final String fieldName,
@Nullable final String sourceFunction, final boolean shortMessage, final String value)
{
if (ex instanceof ParseException)
{
final ParseException parseException = (ParseException) ex;
final String exMessage = parseException.getMessage();
if (exMessage != null)
{
if (exMessage.endsWith("'*' or '?' not allowed as first character in WildcardQuery"))
{
return getErrorMessage(i18n, sourceFunction, shortMessage, fieldName, value, "jira.jql.text.clause.bad.start.in.wildcard");
}
else if (BAD_RANGEIN_PATTERN.matcher(exMessage).matches() || BAD_RANGEEX_PATTERN.matcher(exMessage).matches()) {
return getErrorMessage(i18n, sourceFunction, shortMessage, fieldName, value, "jira.jql.text.clause.incorrect.range.query");
}
}
}
return null;
}
代码示例来源:origin: omero/server
} catch (ParseException pe) {
final String msg = queryStr + " caused a parse exception: " +
pe.getMessage();
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
/**
* Helper utility for parsing a query using the Lucene QueryParser syntax.
* @param qs query expression in standard Lucene syntax
* @param defaultField default field used for unqualified search terms in the query expression
* @param params used to determine the default operator, overriding the schema specified operator
* @param schema used for default operator (overridden by params) and passed to the query parser for field format analysis information
*/
public static Query parseQuery(String qs, String defaultField, SolrParams params, IndexSchema schema) {
try {
SolrQueryParser parser = schema.getSolrQueryParser(defaultField);
String opParam = params.get(OP);
if (opParam != null) {
parser.setDefaultOperator("AND".equals(opParam) ? QueryParser.Operator.AND : QueryParser.Operator.OR);
}
Query query = parser.parse(qs);
if (SolrCore.log.isTraceEnabled() ) {
SolrCore.log.trace("After QueryParser:" + query);
}
return query;
} catch (ParseException e) {
SolrCore.log(e);
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Query parsing error: " + e.getMessage(),e);
}
}
代码示例来源:origin: omero/server
} catch (ParseException pe) {
final String msg = queryStr + " caused a parse exception: " +
pe.getMessage();
代码示例来源:origin: org.ow2.bonita/bonita-server
private FullTextQuery createFullTextQuery(final SearchQueryBuilder query, final Class<?> indexClass) {
QueryParser parser = null;
final String expression = query.getQuery();
if (!expression.contains("\\:")) {
parser = new QueryParser(LUCENE_VERSION, query.getIndex().getDefaultField(), new StandardAnalyzer(LUCENE_VERSION));
} else {
final List<String> list = query.getIndex().getAllFields();
final String[] fields = list.toArray(new String[list.size()]);
parser = new MultiFieldQueryParser(LUCENE_VERSION, fields, new StandardAnalyzer(LUCENE_VERSION));
}
final FullTextSession searchSession = Search.getFullTextSession(getSession());
try {
final org.apache.lucene.search.Query luceneQuery = parser.parse(query.getQuery());
return searchSession.createFullTextQuery(luceneQuery, indexClass);
} catch (final ParseException e) {
throw new BonitaRuntimeException(e.getMessage());
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
"Query parsing with \"legacy\" method, we got ParseException from QueryParser: " + e.getMessage() );
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
/** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
* @param query the query string to be parsed.
* @throws ParseException if the parsing fails
*/
public Query parse(String query) throws ParseException {
ReInit(new FastCharStream(new StringReader(query)));
try {
// TopLevelQuery is a Query followed by the end-of-input (EOF)
Query res = TopLevelQuery(field);
return res!=null ? res : newBooleanQuery(false);
}
catch (ParseException tme) {
// rethrow to include the original query:
throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());
}
catch (TokenMgrError tme) {
throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());
}
catch (BooleanQuery.TooManyClauses tmc) {
throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses");
}
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
/** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
* @param query the query string to be parsed.
* @throws ParseException if the parsing fails
*/
public Query parse(String query) throws ParseException {
ReInit(new FastCharStream(new StringReader(query)));
try {
// TopLevelQuery is a Query followed by the end-of-input (EOF)
Query res = TopLevelQuery(field);
return res!=null ? res : newBooleanQuery(false);
}
catch (ParseException tme) {
// rethrow to include the original query:
throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());
}
catch (TokenMgrError tme) {
throw new ParseException("Cannot parse '" +query+ "': " + tme.getMessage());
}
catch (BooleanQuery.TooManyClauses tmc) {
throw new ParseException("Cannot parse '" +query+ "': too many boolean clauses");
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
throw new IllegalArgumentException("Unable to parse filter into a Lucene query : '"+e.getMessage()+"'");
} catch (IllegalNameException e) {
throw new IllegalArgumentException("Unable to parse filter into a Lucene query : '"+e.getMessage()+"'");
代码示例来源:origin: org.apache.maven.archiva/archiva-indexer
public SearchResults searchForTerm( String principal, List<String> selectedRepos, String term, SearchResultLimits limits )
{
List<RepositoryContentIndex> indexes = getFileContentIndexes( principal, selectedRepos );
try
{
QueryParser parser = new FileContentHandlers().getQueryParser();
LuceneQuery query = new LuceneQuery( parser.parse( term ) );
SearchResults results = searchAll( query, limits, indexes );
results.getRepositories().addAll( this.localIndexedRepositories );
return results;
}
catch ( ParseException e )
{
getLogger().warn( "Unable to parse query [" + term + "]: " + e.getMessage(), e );
}
// empty results.
return new SearchResults();
}
代码示例来源:origin: org.apache.maven.archiva/archiva-indexer
public SearchResults searchForBytecode( String principal, List<String> selectedRepos, String term, SearchResultLimits limits )
{
List<RepositoryContentIndex> indexes = getHashcodeIndexes( principal, selectedRepos );
try
{
QueryParser parser = new BytecodeHandlers().getQueryParser();
LuceneQuery query = new LuceneQuery( parser.parse( term ) );
SearchResults results = searchAll( query, limits, indexes );
results.getRepositories().addAll( this.localIndexedRepositories );
return results;
}
catch ( ParseException e )
{
getLogger().warn( "Unable to parse query [" + term + "]: " + e.getMessage(), e );
}
// empty results.
return new SearchResults();
}
代码示例来源:origin: org.apache.maven.archiva/archiva-indexer
public SearchResults searchForChecksum( String principal, List<String> selectedRepos, String checksum, SearchResultLimits limits )
{
List<RepositoryContentIndex> indexes = getHashcodeIndexes( principal, selectedRepos );
try
{
QueryParser parser = new MultiFieldQueryParser( new String[]{HashcodesKeys.MD5, HashcodesKeys.SHA1},
new HashcodesHandlers().getAnalyzer() );
LuceneQuery query = new LuceneQuery( parser.parse( checksum ) );
SearchResults results = searchAll( query, limits, indexes );
results.getRepositories().addAll( this.localIndexedRepositories );
return results;
}
catch ( ParseException e )
{
getLogger().warn( "Unable to parse query [" + checksum + "]: " + e.getMessage(), e );
}
// empty results.
return new SearchResults();
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
+ e.getMessage() );
代码示例来源:origin: org.xcmis/xcmis-search-service
reporter.reportMessage(e.getMessage());
代码示例来源:origin: org.xcmis/xcmis-search-service
reporter.reportMessage(e.getMessage());
代码示例来源:origin: org.jabylon/index
query.add(userQuery, Occur.MUST);
} catch (ParseException e) {
throw new RuntimeException(e.getMessage(),e);
内容来源于网络,如有侵权,请联系作者删除!