org.apache.lucene.queryparser.classic.ParseException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.apache.lucene.queryparser.classic.ParseException.getMessage()方法的一些代码示例,展示了ParseException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.getMessage()方法的具体详情如下:
包路径:org.apache.lucene.queryparser.classic.ParseException
类名称:ParseException
方法名:getMessage

ParseException.getMessage介绍

暂无

代码示例

代码示例来源:origin: oracle/opengrok

errorMsg = PARSE_ERROR_MSG + e.getMessage();
} catch (FileNotFoundException e) {

代码示例来源:origin: rnewson/couchdb-lucene

+ e.getMessage());
  return;
} finally {

代码示例来源:origin: org.apache.clerezza/rdf.cris.core

@Override
public Query query() {
  try {
    Query q = queryParser.parse(searchQuery);
    return q;
  } catch (ParseException ex) {
    throw new RuntimeException(ex.getMessage());
  }
}

代码示例来源:origin: ontopia/ontopia

@Override
public SearchResultIF search(String query) throws IOException {
 synchronized (READER_LOCK) {
  openReader();
  IndexSearcher searcher = new IndexSearcher(reader);
  try {
   logger.debug("Searching for: '" + query + "'");
   Query _query = new QueryParser(defaultField, ANALYZER).parse(query);
   return new LuceneSearchResult(searcher, searcher.search(_query, Integer.MAX_VALUE));
  } catch (org.apache.lucene.queryparser.classic.ParseException e) {
   logger.error("Error parsing query: '" + e.getMessage() + "'");
   throw new IOException(e.getMessage(), e);
  }
 }
}

代码示例来源:origin: epam/Wilma

private Query createQuery(final String query) {
  Query result = null;
  try {
    result = queryParser.parse(query);
  } catch (ParseException e) {
    throw new QueryCannotBeParsedException("Query " + query + "cannot be parsed. Reason:" + e.getMessage());
  }
  return result;
}

代码示例来源:origin: org.apache.jena/jena-text

@Override
public List<TextHit> query(Node property, String qs, String graphURI, String lang, int limit, String highlight) {
  try (IndexReader indexReader = DirectoryReader.open(directory)) {
    return query$(indexReader, property, qs, UnaryOperator.identity(), graphURI, lang, limit, highlight) ;
  }
  catch (ParseException ex) {
    throw new TextIndexParseException(qs, ex.getMessage()) ;
  }
  catch (Exception ex) {
    throw new TextIndexException("query", ex) ;
  }
}

代码示例来源:origin: apache/jena

@Override
public List<TextHit> query(Node property, String qs, String graphURI, String lang, int limit, String highlight) {
  try (IndexReader indexReader = DirectoryReader.open(directory)) {
    return query$(indexReader, property, qs, UnaryOperator.identity(), graphURI, lang, limit, highlight) ;
  }
  catch (ParseException ex) {
    throw new TextIndexParseException(qs, ex.getMessage()) ;
  }
  catch (Exception ex) {
    throw new TextIndexException("query", ex) ;
  }
}

代码示例来源:origin: apache/jena

@Override
public List<TextHit> query(String subjectUri, Node property, String qs, String graphURI, String lang, int limit, String highlight) {
  try (IndexReader indexReader = DirectoryReader.open(directory)) {
    return query$(indexReader, property, qs, addUriPredicate(subjectUri), graphURI, lang, limit, highlight) ;
  }
  catch (ParseException ex) {
    throw new TextIndexParseException(qs, ex.getMessage()) ;
  }
  catch (Exception ex) {
    throw new TextIndexException("query", ex) ;
  }
}

代码示例来源:origin: org.apache.jena/jena-text

@Override
public List<TextHit> query(String subjectUri, Node property, String qs, String graphURI, String lang, int limit, String highlight) {
  try (IndexReader indexReader = DirectoryReader.open(directory)) {
    return query$(indexReader, property, qs, addUriPredicate(subjectUri), graphURI, lang, limit, highlight) ;
  }
  catch (ParseException ex) {
    throw new TextIndexParseException(qs, ex.getMessage()) ;
  }
  catch (Exception ex) {
    throw new TextIndexException("query", ex) ;
  }
}

代码示例来源:origin: com.orientechnologies/orientdb-lucene

private Query getQuery(OIndexDefinition index, String query, ODocument metadata, Analyzer queryAnalyzer, String[] fields,
  Map<String, OType> types) throws ParseException {
 Map<String, Float> boost = Optional.ofNullable(metadata.<Map<String, Float>>getProperty("boost")).orElse(new HashMap<>());
 Analyzer analyzer = Optional.ofNullable(metadata.<Boolean>getProperty("customAnalysis")).filter(b -> b == true)
   .map(b -> analyzerFactory.createAnalyzer(index, OLuceneAnalyzerFactory.AnalyzerKind.QUERY, metadata)).orElse(queryAnalyzer);
 final OLuceneMultiFieldQueryParser queryParser = new OLuceneMultiFieldQueryParser(types, fields, analyzer, boost);
 queryParser.setAllowLeadingWildcard(
   Optional.ofNullable(metadata.<Boolean>getProperty("allowLeadingWildcard")).orElse(allowLeadingWildcard));
 queryParser.setSplitOnWhitespace(
   Optional.ofNullable(metadata.<Boolean>getProperty("splitOnWhitespace")).orElse(splitOnWhitespace));
 //  TODO   REMOVED
 //    queryParser.setLowercaseExpandedTerms(
 //        Optional.ofNullable(metadata.<Boolean>getProperty("lowercaseExpandedTerms"))
 //            .orElse(lowercaseExpandedTerms));
 try {
  return queryParser.parse(query);
 } catch (org.apache.lucene.queryparser.classic.ParseException e) {
  OLogManager.instance().error(this, "Exception is suppressed, original exception is ", e);
  //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException
  throw new ParseException(e.getMessage());
 }
}

代码示例来源:origin: Stratio/cassandra-lucene-index

/** {@inheritDoc} */
@Override
public Query doQuery(Schema schema) {
  try {
    Analyzer analyzer = schema.analyzer;
    QueryParser queryParser = new QueryParser(defaultField, analyzer);
    queryParser.setAllowLeadingWildcard(true);
    queryParser.setLowercaseExpandedTerms(false);
    return queryParser.parse(query);
  } catch (ParseException e) {
    throw new IndexException("Error while parsing lucene syntax query: {}", e.getMessage());
  }
}

代码示例来源:origin: metatron-app/metatron-discovery

@Override
public Page<DataSource> searchByQuery(String query, Pageable pageable) {
 final FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
 LOGGER.info("Query : {}, Pageable: {}", query, pageable);
 FullTextQuery fullTextQuery;
 try {
  final QueryParser queryParser = new QueryParser("content", fullTextEntityManager.getSearchFactory().getAnalyzer(DataSource.class));
  fullTextQuery = fullTextEntityManager.createFullTextQuery(queryParser.parse(query), DataSource.class);
 } catch (ParseException e) {
  LOGGER.error("Fail to search query : {}", e.getMessage());
  throw new RuntimeException("Fail to search query : " + e.getMessage());
 }
 fullTextQuery.setFirstResult(pageable.getOffset());
 fullTextQuery.setMaxResults(pageable.getPageSize());
 fullTextQuery.setSort(getSearchSort(pageable));
 LOGGER.debug("FullTextQuery : {}", fullTextQuery);
 return new PageImpl<>(fullTextQuery.getResultList(), pageable, fullTextQuery.getResultSize());
}

代码示例来源:origin: com.atlassian.bonnie/atlassian-bonnie

/**
 * Different from term query in that the query parameter specified is passed through an analyzer that may
 * remove certain stop words before constructing a Query. Desirable for full text search fields. Undesirable for keyword
 * searches (build a Term query instead).
 *
 * @param searchFields
 * @param query
 */
public Query buildStandardQuery(String[] searchFields, String query)
{
  Query myquery;
  try
  {
    QueryParser qp = makeQueryParserForSearchFields(searchFields);
    qp.setDefaultOperator(QueryParser.Operator.AND);
    myquery = qp.parse(query);
  }
  catch (ParseException e)
  {
    throw new LuceneException("Couldn't parse the query successfully:" + e.getMessage());
  }
  return myquery;
}

代码示例来源:origin: metatron-app/metatron-discovery

@Override
public Page<Role> searchByQuery(String query, Pageable pageable) {
 final FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
 FullTextQuery fullTextQuery;
 try {
  final QueryParser queryParser = new QueryParser("name", fullTextEntityManager.getSearchFactory().getAnalyzer(Role.class));
  Query parsedQuery = queryParser.parse(query);
  LOGGER.debug("{}, Parsed {}", query, parsedQuery);
  fullTextQuery = fullTextEntityManager.createFullTextQuery(parsedQuery, Role.class);
 } catch (ParseException e) {
  e.printStackTrace();
  throw new RuntimeException("Fail to search query : " + e.getMessage());
 }
 fullTextQuery.setFirstResult(pageable.getOffset());
 fullTextQuery.setMaxResults(pageable.getPageSize());
 Sort sort = getSearchSort(pageable);
 LOGGER.debug("Sort : {}", Arrays.toString(sort.getSort()));
 if(sort.getSort().length > 0) {
  fullTextQuery.setSort(getSearchSort(pageable));
 }
 return new PageImpl<>(fullTextQuery.getResultList(), pageable, fullTextQuery.getResultSize());
}

代码示例来源:origin: metatron-app/metatron-discovery

@Override
public Page<User> searchByQuery(@Param("q") String query, Pageable pageable) {
 final FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
 FullTextQuery fullTextQuery;
 try {
  final QueryParser queryParser = new QueryParser("content", fullTextEntityManager.getSearchFactory().getAnalyzer(User.class));
  fullTextQuery = fullTextEntityManager.createFullTextQuery(queryParser.parse(query), User.class);
 } catch (ParseException e) {
  e.printStackTrace();
  throw new RuntimeException("Fail to search query : " + e.getMessage());
 }
 fullTextQuery.setFirstResult(pageable.getOffset());
 fullTextQuery.setMaxResults(pageable.getPageSize());
 fullTextQuery.setSort(getSearchSort(pageable));
 return new PageImpl<>(fullTextQuery.getResultList(), pageable, fullTextQuery.getResultSize());
}

代码示例来源:origin: msokolov/lux

return luxQueryParser.parse(queryArg.getStringValue());
} catch (ParseException e) {
  throw new XPathException (e.getMessage(), e);

代码示例来源:origin: org.infinispan/infinispan-embedded-query

@Override
public Query getQuery(Element e) throws ParserException {
 String text = DOMUtils.getText(e);
 try {
  Query q = null;
  if (unSafeParser != null) {
   //synchronize on unsafe parser
   synchronized (unSafeParser) {
    q = unSafeParser.parse(text);
   }
  } else {
   String fieldName = DOMUtils.getAttribute(e, "fieldName", defaultField);
   //Create new parser
   QueryParser parser = createQueryParser(fieldName, analyzer);
   q = parser.parse(text);
  }
  float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
  return new BoostQuery(q, boost);
 } catch (ParseException e1) {
  throw new ParserException(e1.getMessage());
 }
}

代码示例来源:origin: apache/incubator-atlas

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;
}

代码示例来源:origin: metatron-app/metatron-discovery

@Override
public Page<PrDataset> searchByQuery(String query, Pageable pageable) {
  final FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
  FullTextQuery fullTextQuery;
  try {
    final QueryParser queryParser = new QueryParser("content", fullTextEntityManager.getSearchFactory().getAnalyzer(PrDataset.class));
    fullTextQuery = fullTextEntityManager.createFullTextQuery(queryParser.parse(query), PrDataset.class);
  } catch (ParseException e) {
    e.printStackTrace();
    throw new RuntimeException("Fail to search query : " + e.getMessage());
  }
  fullTextQuery.setFirstResult(pageable.getOffset());
  fullTextQuery.setMaxResults(pageable.getPageSize());
  return new PageImpl<>(fullTextQuery.getResultList(), pageable, fullTextQuery.getResultSize());
}

代码示例来源:origin: harbby/presto-connectors

@Override
public Query getQuery(Element e) throws ParserException {
 String text = DOMUtils.getText(e);
 try {
  Query q = null;
  if (unSafeParser != null) {
   //synchronize on unsafe parser
   synchronized (unSafeParser) {
    q = unSafeParser.parse(text);
   }
  } else {
   String fieldName = DOMUtils.getAttribute(e, "fieldName", defaultField);
   //Create new parser
   QueryParser parser = createQueryParser(fieldName, analyzer);
   q = parser.parse(text);
  }
  float boost = DOMUtils.getAttribute(e, "boost", 1.0f);
  return new BoostQuery(q, boost);
 } catch (ParseException e1) {
  throw new ParserException(e1.getMessage());
 }
}

相关文章