Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
TestSearch.java
Package: lucene+mysql+eclipe.rar [view]
Upload User: zhihansy
Upload Date: 2014-12-04
Package Size: 7241k
Code Size: 2k
Category:
Search Engine
Development Platform:
Java
- package com.lucene;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.util.Date;
- import java.util.List;
- import org.apache.lucene.queryParser.ParseException;
- import org.apache.lucene.search.IndexSearcher;
- import org.apache.lucene.search.Searcher;
- /*
- *@author 申华锋 E-mail:leonshine@qq.com
- *@version 创建时间:Mar 9, 2008 12:12:45 AM
- *@description 测试
- */
- public class TestSearch {
- public final static String indexDir = "D:\TestLucene";
- public static List lucene(String[] q, int startIndex, int endIndex) throws IOException, ParseException,
- SQLException {
- //index();// 做索引
- Searcher searcher = null;
- List lst = null;
- try {
- searcher = new IndexSearcher(indexDir);
- // String[] q = { "apache", "三星", "ibmd", "micronnnst" };
- //long start = new Date().getTime();
- lst = SearcherFile.search(searcher, q, startIndex, endIndex);
- //long end = new Date().getTime();
- //System.out.println("花费时间:" + (double) (end - start) / 1000 + "秒");
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (searcher != null)
- searcher.close();
- }
- return lst;
- }
- /*public static void main(String[] args) throws IOException, ParseException, SQLException {
- index();//做索引
- Searcher searcher=null;
- try{
- searcher = new IndexSearcher(indexDir);
- String[] q = { "apache", "11", "11", "1" };
- search(searcher, q);//搜索
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- if(searcher!=null)
- searcher.close();
- }
- }*/
- public static void index() throws SQLException {
- Connection conn = null;
- try {
- conn = DBConnection.getConnection();
- Product[] list = Product.loadProducts();
- IndexerFile.indexFile(indexDir, list);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (conn != null) {
- conn.close();
- }
- }
- }
- }