本文整理匯總了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();
}
}
}