这是我的 JSP 代码:
<%@page import="java.util.Calendar"%> <%@ page import="org.apache.lucene.search.IndexSearcher"%> <%@ page import="org.apache.lucene.analysis.Analyzer"%> <%@ page import="org.apache.lucene.analysis.snowball.SnowballAnalyzer"%> <%@ page import="org.apache.lucene.search.Hits"%> <%@ page import="org.apache.lucene.queryParser.QueryParser"%> <%@ page import="org.apache.lucene.queryParser.MultiFieldQueryParser"%> <%@ page import="org.apache.lucene.queryParser.ParseException"%>
<%@ page import="org.apache.lucene.queryParser.QueryParser"%> <%@ page import="org.apache.lucene.search.Query"%>
<%@ page import="org.apache.lucene.util.Version"%> <%@ page import="org.apache.lucene.store.FSDirectory"%> <%@ page import="org.apache.lucene.search.ScoreDoc"%> <%@ page import="org.apache.lucene.document.Document"%> <%@ page import="org.apache.lucene.search.ScoreDoc"%>
<%@ page import="org.apache.lucene.index.IndexReader"%>
<%@ page import="java.io.IOException"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.io., java.net."%>
<% //out.print("Today is:"+Calendar.getInstance().getTimeInMillis());
String fil = "E:\\cbdtindex";
Analyzer analyzer = new SnowballAnalyzer("English");
IndexSearcher indexSearcher;
String[] fields = { "DocType1" };
try {
// Directory indexDir = FSDirectory.open(findexfile);
IndexReader reader = IndexReader.open(
FSDirectory.open(new File(fil)), true);
indexSearcher = new IndexSearcher(reader);
MultiFieldQueryParser parser = new MultiFieldQueryParser(
fields, analyzer);
Query query = parser.parse("dtl");
ScoreDoc[] hits = indexSearcher.search(query, null, 100000).scoreDocs;
int x = hits.length;
for (int i = 0; i < x; i++) {
Document hitDoc = indexSearcher.doc(hits[i].doc);
String p = hitDoc.get("FilePath");
//System.out.println(p);
out.println(p);
}
System.out.println("Length" + x);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
%>
我想在列表网格或表格中显示字符串 P 值。
有人能帮我吗?我可以out.print.ln
在控制台上打印显示数据,但我需要在列表中显示。