uSniff:BT种子搜索引擎
- leqoqo - 软件志一、uSniff相关信息: 1、官方主页:http://www.usniff.com/ 2、简介:uSniff是一个BT种子搜索引擎,简单、易用、实时是其最大的优点,其搜索引擎数据库包含了17个知名种子站点的种子信息,目的是想发展成为世界上最大的BT种子搜索引擎,而且对于每个种子,该搜索引擎都会进行安全认证,以保证用户的正常使用.
package com.java.search; import java.io.File; import java.io.IOException; import java.util.Date; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Field.Index; import org.apache.lucene.document.Field.Store; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.util.Version; public class Searcher { public void test() throws IOException { File file = new File("f://youyajie"); FSDirectory directory = FSDirectory.open(file); //用来创建索引 IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_36, new StandardAnalyzer(Version.LUCENE_36)); IndexWriter writer = new IndexWriter(directory, conf); Document doc1 = new Document(); Document doc2 = new Document(); Document doc3 = new Document(); Document doc4 = new Document(); Document doc5 = new Document(); Document doc6 = new Document(); Document doc7 = new Document(); Document doc8 = new Document(); Field f1 = new Field("bookname", "钢铁是怎样炼成的", Store.YES, Index.ANALYZED); Field f2 = new Field("bookname", "英雄儿女", Store.YES, Index.ANALYZED); Field f3 = new Field("bookname", "篱笆女人和狗", Store.YES, Index.ANALYZED); Field f4 = new Field("bookname", "格林童话", Store.YES, Index.ANALYZED); Field f5 = new Field("bookname", "钢和铁是两种金属", Store.YES, Index.ANALYZED); Field f6 = new Field("bookname", "白毛女", Store.YES, Index.ANALYZED); Field f7 = new Field("bookname", "钢的世界", Store.YES, Index.ANALYZED); Field f8 = new Field("bookname", "钢铁战士", Store.YES, Index.ANALYZED); doc1.add(f1); doc2.add(f2); doc3.add(f3); doc4.add(f4); doc5.add(f5); doc6.add(f6); doc7.add(f7); doc8.add(f8); writer.addDocument(doc1); writer.addDocument(doc2); writer.addDocument(doc3); writer.addDocument(doc4); writer.addDocument(doc5); writer.addDocument(doc6); writer.addDocument(doc7); writer.addDocument(doc8); writer.close();//一定要关闭writer,这样索引才能写到磁盘上 IndexReader reader = IndexReader.open(directory); //简单索引 IndexSearcher searcher = new IndexSearcher(reader); Term t = new Term("bookname", "钢"); TermQuery quenry = new TermQuery(t); //获得得分靠前的两个匹配记录 ScoreDoc[] docs = searcher.search(quenry, 2).scoreDocs; for(int i = 0; i < docs.length; i++) { Date start = new Date(); String bookname = searcher.doc(docs[i].doc).get("bookname"); Date end = new Date(); System.out.println(bookname + (end.getTime() - start.getTime()) + "ms"); } } public static void main(String[] args) throws IOException { Searcher Test = new Searcher(); Test.test(); } }
钢的世界2ms 钢铁战士1ms