<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "看書做一個 Lucene 提供的 index 可是... 出現5個bug可是卻不知道是哪邊打錯了？"]]></title>
		<link>https://forum.andowson.com/posts/list/5.page</link>
		<description><![CDATA[Latest messages posted in the topic "看書做一個 Lucene 提供的 index 可是... 出現5個bug可是卻不知道是哪邊打錯了？"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>看書做一個 Lucene 提供的 index 可是... 出現5個bug可是卻不知道是哪邊打錯了？</title>
				<description><![CDATA[ 看書做一個 Lucene 提供的 index 可是... 出現5個bug可是卻不知道是哪邊打錯了？ 
<br>
可以請前輩指導一下嗎？ 
<br>
<br>
感激不盡&lt;(_ _)&gt; 
<br>
<br>
圖片如下： 
<br>
[url]http://img130.imageshack.us/f/bug01.jpg/[/url] 
<br>
<br>
<br>
程式碼如下： 
<br>
[code] 
<br>
import java.io.File; 
<br>
import java.io.FileReader; 
<br>
import java.io.Reader; 
<br>
import java.io.FileFilter; 
<br>
import java.util.Date; 
<br>
import org.apache.lucene.analysis.*; 
<br>
import org.apache.lucene.analysis.Analyzer; 
<br>
import org.apache.lucene.analysis.standard.StandardAnalyzer; 
<br>
import org.apache.lucene.document.Document; 
<br>
import org.apache.lucene.document.Field; 
<br>
import org.apache.lucene.index.IndexWriter; 
<br>
<br>
public class TxtFileIndex 
<br>
{ 
<br>
 public static void main(String[] args) throws Exception 
<br>
 { 
<br>
 File dataDir = new File("C:\\IR\\IR_TEST"); 
<br>
 File indexDir = new File("C:\\IR\\IR_index"); 
<br>
<br>
 Analyzer luceneAnalyzer = new StandardAnalyzer(); 
<br>
 File[] dataFiles = dataDir.listFiles(); 
<br>
<br>
 IndexWriter indexWriter = new IndexWriter(indexDir,luceneAnalyzer,true); 
<br>
<br>
 long startTime = new Date().getTime(); 
<br>
 for (int i=0;i&lt;dataFiles.length;i++) 
<br>
 { 
<br>
 if(dataFiles[i].isFile() &amp;&amp; dataFiles[i].getName().endsWith(".txt")) 
<br>
 { 
<br>
 System.out.println("Idx"+dataFiles[i].getCanonicalPath()); 
<br>
<br>
 Document document = Document(); 
<br>
 Reader txtReader = new FileReader(dataFiles[i]); 
<br>
 document.add(new Field("path", dataFiles[i].getCanonicalPath(), Field.Store.YES, Field.Index.UN_TOKENIZED)); 
<br>
 document.add(new Field("contents, txtReader")); 
<br>
 } 
<br>
 } 
<br>
 indexWriter.optimize(); 
<br>
 indexWriter.close(); 
<br>
 long endTime = new Date().getTime(); 
<br>
<br>
 System.out.println("It take "+ (endTime - startTime) + "milliseconds to create index for the files in directory." + dataDir.getPath()); 
<br>
<br>
 } 
<br>
} 
<br>
[/code]]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/466/958.page</guid>
				<link>https://forum.andowson.com/posts/preList/466/958.page</link>
				<pubDate><![CDATA[Mon, 17 Jan 2011 16:34:32]]> GMT</pubDate>
				<author><![CDATA[ crc2121]]></author>
			</item>
			<item>
				<title>回覆:看書做一個 Lucene 提供的 index 可是... 出現5個bug可是卻不知道是哪邊打錯了？</title>
				<description><![CDATA[ 乍看之下應該是CLASSPATH內找不到相關的jar檔，你有下載Lucene需要的jar檔嗎？]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/466/959.page</guid>
				<link>https://forum.andowson.com/posts/preList/466/959.page</link>
				<pubDate><![CDATA[Tue, 18 Jan 2011 18:33:46]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:看書做一個 Lucene 提供的 index 可是... 出現5個bug可是卻不知道是哪邊打錯了？</title>
				<description><![CDATA[ 已修正完~]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/466/960.page</guid>
				<link>https://forum.andowson.com/posts/preList/466/960.page</link>
				<pubDate><![CDATA[Wed, 19 Jan 2011 14:30:33]]> GMT</pubDate>
				<author><![CDATA[ crc2121]]></author>
			</item>
	</channel>
</rss>