文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>检索源代码(成功运行!)

检索源代码(成功运行!)

时间:2007-07-31  来源:sdwsyjp

package test; import java.io.IOException; import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
public class Searcher3 {  /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  try {
   IndexSearcher searcher = new IndexSearcher(Constants.INDEX_STORE_PATH);
   Query query = null;
   Hits hits = null;
   QueryParser qp = new QueryParser("contents",new StandardAnalyzer());
   try {
    query = qp.parse("金鹏");
   } catch (ParseException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
   hits = searcher.search(query);
   System.out.println(hits.length());
  } catch (CorruptIndexException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  
 } }
  运行结果为:7,^_^
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载