本文整理汇总了Java中org.apache.lucene.queryparser.classic.ParseException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ParseException.printStackTrace方法的具体用法?Java ParseException.printStackTrace怎么用?Java ParseException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.queryparser.classic.ParseException
的用法示例。
在下文中一共展示了ParseException.printStackTrace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runQuery
import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
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;
}
示例2: queryIndex
import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
public static LuceneSearchResult queryIndex(String keyword, int offset, int pagesize){
// 查询
List<Query> querys = new ArrayList<>();
if (keyword!=null && keyword.trim().length()>0) {
try {
//Analyzer analyzer = new SmartChineseAnalyzer();
Analyzer analyzer = new IKAnalyzer();
QueryParser parser = new QueryParser(ExcelUtil.KEYWORDS, analyzer);
Query shopNameQuery = parser.parse(keyword);
querys.add(shopNameQuery);
} catch (ParseException e) {
e.printStackTrace();
}
}
LuceneSearchResult result = search(querys, offset, pagesize);
return result;
}
示例3: getHits
import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
private ScoreDoc[] getHits(String question) throws IOException {
try {
Query luceneQuery = queryParser.parse(question);
ScoreDoc[] hits = indexSearcher.search(luceneQuery, numOfDocs).scoreDocs;
return hits;
}
catch (ParseException e) {
System.out.println("ParseException question = " + question);
e.printStackTrace();
return new ScoreDoc[0];
}
}
示例4: main
import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
/**
* @decription:测试
* @parm:@param args
* @return:void
* @throws:IOException
*/
public static void main(String[] args) throws IOException {
SearchDao test = new SearchDao();
try {
System.out.println(test.searcher("虎溪校区举行辅导员座谈会"));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例5: search
import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
@Override
public List<String> search(String text) {
if (src != null && src.isSupported(TermDataSourceFeature.SEARCH)) return src.search(text);
try {
return search(this.parser.parse(text));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
示例6: load
import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
public void load(String filename) throws Exception {
BufferedReader in = new BufferedReader(new FileReader(filename));
String line = null;
QueryParser qps = new QueryParser(FreebaseTools.FIELD_NAME_TEXT, tools.getIndexAnalyzer());
IndexSearcher searcher = tools.getIndexSearcher();
IndexReader reader = tools.getIndexReader();
while ((line = in.readLine()) != null) {
String[] fields = line.split("\t");
System.out.println("[Query: " + fields[0] + "] [KBid: " + fields[1] + "] [type: " + fields[2] + "]");
try {
// execute a Lucene query for the entity, get back 10 docs
Query q = qps.parse(fields[0]);
TopDocs results = searcher.search(q, 10);
ScoreDoc[] hits = results.scoreDocs;
boolean found = false;
long Ndocs = reader.numDocs();
for (ScoreDoc sd : hits) {
// - if d is the relevant doc, then found=true, this one's relevant.
boolean rel = false;
Document d = tools.getDocumentInMode(sd.doc);
String kbid = d.get("subject");
if (kbid.equals(fields[1])) {
found = true;
rel = true;
}
// - get its termvector
Fields docfields = reader.getTermVectors(sd.doc);
// - make it into what jforests wants
for (String f : docfields) {
TermsEnum t = docfields.terms(f).iterator();
BytesRef tstring;
while ((tstring = t.next()) != null) {
PostingsEnum pe = t.postings(null);
int i;
int df = t.docFreq();
while ((i = pe.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
int freq = pe.freq();
double idf = Math.log(Ndocs / df);
double tf = 1 + Math.log(freq);
double tfidf = tf * idf;
// and that's the weight.
}
}
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}