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

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

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

ParseException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: dermotte/LIRE

public ImageSearchHits search(Document doc, IndexReader reader) throws IOException {
  SimpleImageSearchHits sh = null;
  IndexSearcher isearcher = new IndexSearcher(reader);
  isearcher.setSimilarity(similarity);
  String queryString = doc.getValues(fieldName)[0];
  Query tq = null;
  try {
    tq = qp.parse(queryString);
    TopDocs docs = isearcher.search(tq, numMaxHits);
    LinkedList<SimpleResult> res = new LinkedList<SimpleResult>();
    double maxDistance = 0d;
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      double d = 1d / docs.scoreDocs[i].score;
      maxDistance = Math.max(d, maxDistance);
      SimpleResult sr = new SimpleResult(d, docs.scoreDocs[i].doc);
      res.add(sr);
    }
    sh = new SimpleImageSearchHits(res, maxDistance);
  } catch (ParseException e) {
    System.err.println(queryString);
    e.printStackTrace();
  }
  return sh;
}

代码示例来源:origin: dermotte/LIRE

public ImageSearchHits search(Document doc, IndexReader reader) throws IOException {
  SimpleImageSearchHits sh = null;
  IndexSearcher isearcher = new IndexSearcher(reader);
  isearcher.setSimilarity(similarity);
  String queryString = doc.getValues(fieldName)[0];
  Query tq = null;
  try {
    tq = qp.parse(queryString);
    TopDocs docs = isearcher.search(tq, numMaxHits);
    LinkedList<SimpleResult> res = new LinkedList<SimpleResult>();
    double maxDistance = 0d;
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      double d = 1d / docs.scoreDocs[i].score;
      maxDistance = Math.max(d, maxDistance);
      SimpleResult sr = new SimpleResult(d, docs.scoreDocs[i].doc);
      res.add(sr);
    }
    sh = new SimpleImageSearchHits(res, maxDistance);
  } catch (ParseException e) {
    System.err.println(queryString);
    e.printStackTrace();
  }
  return sh;
}

代码示例来源:origin: dermotte/LIRE

query = qp.parse(hashes);
} catch (ParseException e) {
  e.printStackTrace();

代码示例来源:origin: dermotte/LIRE

query = qp.parse(hashes);
} catch (ParseException e) {
  e.printStackTrace();

代码示例来源:origin: dermotte/LIRE

query = qp.parse(hashes);
} catch (ParseException e) {
  e.printStackTrace();

代码示例来源:origin: dermotte/LIRE

query = qp.parse(hashes);
} catch (ParseException e) {
  e.printStackTrace();

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

public ScoreDoc[] runQuery(String qno, String queryTerms){
  ScoreDoc[] hits = null;
  System.out.println("Query No.: " + qno + " " + queryTerms);
  try {
    Query query = parser.parse(QueryParser.escape(queryTerms));
    try {
      TopDocs results = searcher.search(query, p.maxResults);
      hits = results.scoreDocs;
    }
    catch (IOException ioe){
      ioe.printStackTrace();
      System.exit(1);
    }
  } catch (ParseException pe){
    pe.printStackTrace();
    System.exit(1);
  }
  return hits;
}

代码示例来源:origin: chrismattmann/lucene-geo-gazetteer

private HashMap<String, List<Location>> resolveEntities(List<String> locationNames,
                           int count, IndexReader reader) throws IOException {
  if (locationNames.size() >= 200)
    hitsPerPage = 5; // avoid heavy computation
  IndexSearcher searcher = new IndexSearcher(reader);
  Query q = null;
  HashMap<String, List<Location>> allCandidates = new HashMap<String, List<Location>>();
  for (String name : locationNames) {
    if (!allCandidates.containsKey(name)) {
      try {
        //query is wrapped in additional quotes (") to avoid query tokenization on space
        q = new MultiFieldQueryParser(new String[] { FIELD_NAME_NAME,
            FIELD_NAME_ALTERNATE_NAMES }, analyzer).parse(String.format("\"%s\"", name) );
        Sort sort = new Sort(populationSort);
        //Fetch 3 times desired values, these will be sorted on code and only desired number will be kept
        ScoreDoc[] hits = searcher.search(q, hitsPerPage * 3 , sort).scoreDocs;
        getMatchingCandidates(searcher, allCandidates, name, hits);
      } catch (org.apache.lucene.queryparser.classic.ParseException e) {
        e.printStackTrace();
      }
    }
  }
  HashMap<String, List<Location>> resolvedEntities = new HashMap<String, List<Location>>();
  pickBestCandidates(resolvedEntities, allCandidates, count);
  return resolvedEntities;
}

代码示例来源:origin: com.github.kzwang/lire

public ImageSearchHits search(Document doc, IndexReader reader) throws IOException {
  SimpleImageSearchHits sh = null;
  IndexSearcher isearcher = new IndexSearcher(reader);
  isearcher.setSimilarity(similarity);
  String queryString = doc.getValues(fieldName)[0];
  Query tq = null;
  try {
    tq = qp.parse(queryString);
    TopDocs docs = isearcher.search(tq, numMaxHits);
    LinkedList<SimpleResult> res = new LinkedList<SimpleResult>();
    float maxDistance = 0;
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      float d = 1f / docs.scoreDocs[i].score;
      maxDistance = Math.max(d, maxDistance);
      SimpleResult sr = new SimpleResult(d, reader.document(docs.scoreDocs[i].doc), i);
      res.add(sr);
    }
    sh = new SimpleImageSearchHits(res, maxDistance);
  } catch (ParseException e) {
    System.err.println(queryString);
    e.printStackTrace();
  }
  return sh;
}

代码示例来源:origin: org.apache.ctakes/ctakes-dictionary-lookup

e.printStackTrace();

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

e.printStackTrace();

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

private ArrayList<Double> runQuery(String qno, String queryTerms) {
  ArrayList<Double> predictions = new ArrayList<>();
  System.out.println("Query No.: " + qno + " " + queryTerms);
  try {
    Query query = parser.parse(QueryParser.escape(queryTerms));
    for (QPPredictor predictor : prePredictors) {
      double val = predictor.scoreQuery(qno, query);
      predictions.add(val);
    }
    for (PostQPPredictor predictor : postPredictors) {
      double val;
      if (predictor.getRun().getTopic(qno).size() > 0) {
        val = predictor.scoreQuery(qno, query);
      } else {
        val = 0;
      }
      predictions.add(val);
    }
  } catch (ParseException pe) {
    pe.printStackTrace();
    System.exit(1);
  }
  return predictions;
}

代码示例来源:origin: macluq/HelloLucene

q = new QueryParser(Version.LUCENE_40, "title", analyzer).parse(querystr);
} catch (org.apache.lucene.queryparser.classic.ParseException e) {
  e.printStackTrace();

代码示例来源:origin: hibernate/hibernate-search

protected FullTextQuery getQuery(String queryString, FullTextSession s, Class... classes) {
  Query luceneQuery = null;
  try {
    luceneQuery = parsers.get().parse( queryString );
  }
  catch (ParseException e) {
    e.printStackTrace();
  }
  return s.createFullTextQuery( luceneQuery, classes );
}

代码示例来源:origin: magese/ik-analyzer-solr7

return qp.parse(keywordBuffer_Short.toString());
} catch (ParseException e) {
  e.printStackTrace();
    return qp.parse(keywordBuffer.toString());
  } catch (ParseException e) {
    e.printStackTrace();

代码示例来源:origin: hibernate/hibernate-search

private FullTextQuery getQuery(String queryString, QueryParser parser, Session s) {
    Query luceneQuery = null;
    try {
      luceneQuery = parser.parse( queryString );
    }
    catch (ParseException e) {
      e.printStackTrace();
    }
    return Search.getFullTextSession( s ).createFullTextQuery( luceneQuery );
  }
}

代码示例来源:origin: hibernate/hibernate-search

private FullTextQuery getQuery(String queryString, QueryParser parser, Session s) {
    Query luceneQuery = null;
    try {
      luceneQuery = parser.parse( queryString );
    }
    catch (ParseException e) {
      e.printStackTrace();
    }
    return Search.getFullTextSession( s ).createFullTextQuery( luceneQuery );
  }
}

代码示例来源: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: 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());
}

相关文章