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
SearcherFile.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 org.apache.lucene.analysis.Analyzer;
- import org.apache.lucene.analysis.standard.StandardAnalyzer;
- import org.apache.lucene.document.Document;
- import org.apache.lucene.queryParser.MultiFieldQueryParser;
- import org.apache.lucene.queryParser.ParseException;
- import org.apache.lucene.search.Hits;
- import org.apache.lucene.search.Query;
- import org.apache.lucene.search.Searcher;
- import java.util.*;
- import jeasy.analysis.MMAnalyzer;;
- /*
- * @CopyRigth(R) 城市通
- * @author 申华锋 E-mail:leonshine@qq.com
- * @version 创建时间:Mar 9, 2008 12:12:45 AM
- * @description
- */
- public class SearcherFile {
- private static int hitslength = 0;
- public static List search(Searcher searcher, String[] q, int startIndex,int endIndex)
- throws IOException, ParseException {
- //Analyzer analyzer = new StandardAnalyzer();
- Analyzer analyzer = new MMAnalyzer();//实例化jeasy分词器
- String[] fields = { "title", "description", "tag", "userName" };
- Query query = MultiFieldQueryParser.parse(q, fields, analyzer);
- Hits hits = searcher.search(query);
- hitslength = hits.length();
- System.out.println("Hits总长度"+hits.length());
- List lst = new ArrayList();
- /*for (int i = 0; i < hits.length(); i++) {
- Document doc = hits.doc(i);
- //取出ID,存入List
- lst.add(doc.get("productId"));
- }*/
- if(endIndex>=hits.length())
- endIndex=hits.length()-1;
- List docs=new ArrayList();
- for(int i=startIndex;i<=endIndex;i++){
- Document doc=hits.doc(i);
- lst.add(doc.get("productId"));
- }
- return lst;
- }
- public static int getHitsLength(){
- return hitslength;
- }
- }