0
void Application_Start(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(createIndex));
thread.Start();
}
void createIndex()
{
string constring = "server=localhost;port=3306;database=hr;uid=root;password=root" ;
String luceneIndexDirectory = @"C:\Index";
try
{
SimpleAnalyzer analyzer = new SimpleAnalyzer();
Directory directory = new SimpleFSDirectory(new File(luceneIndexDirectory));
IndexWriter iwriter = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
MySqlConnection con = new MySqlConnection(constring);
MySqlCommand com = new MySqlCommand("select emp_id , emp_resume from emp;", con);
con.Open();
MySqlDataReader dr = com.ExecuteReader();
object objPath = null;
object missing = System.Reflection.Missing.Value;
object objTrue = true;
object objFalse = false;
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
while (dr.Read())
{
objPath = Server.MapPath("~") + @"\Cnd_Resume\" + dr.GetString(1);
if(System.IO.File.Exists(Convert.ToString(objPath)))
{
Microsoft.Office.Interop.Word.Document d = wordApp.Documents.Open(ref objPath, ref objFalse, ref objTrue,
ref objFalse, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref objFalse, ref missing, ref missing, ref missing, ref missing);
Document doc = new Document();
doc.add(new Field("id", dr.GetString(0) , Field.Store.YES , Field.Index.NOT_ANALYZED));
doc.add(new Field("name", dr.GetString(1), Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("contents", d.Content.Text, Field.Store.NO, Field.Index.ANALYZED));
d.Close(ref missing, ref missing, ref missing);
iwriter.addDocument(doc);
}
}
iwriter.optimize();
iwriter.close();
}
catch (Exception ex){}
}
어플에서 시작한 것은 무엇입니까? 거기 정말 필요한가요? 스톱워치를 사용하여 작업 시간을 확인해 보았습니까? http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx – Hawxby
느린 말은 .. 프로그램이 응답하지 않거나 시간이 많이 걸리는 것입니다 .. –
ok please 당신도이 코드를 옮길 것을 제안합니까? 나는 ms 워드 문서에서 lucene 색인을 만들려고 노력 중입니다 ... – richards