Public bool loadconfig (string filename)
{
System. xml. xmldocument Doc = new system. xml. xmldocument ();
Try
{
Doc. Load (filename );
Xmlnode confignode = Doc. selectsinglenode ("luceneconfig ");
Createindexpath = confignode. selectsinglenode ("createindexpath"). innertext; // index Creation Path
Searchindexpath = confignode. selectsinglenode ("createindexpath"). innertext; // search path
Dictpath = confignode. selectsinglenode ("dictpath"). innertext;
// Database Query
Xmlnode datasource = confignode. selectsinglenode ("datasource ");
String Server = datasource. selectsinglenode ("SQL _host"). innertext;
String user = datasource. selectsinglenode ("SQL _user"). innertext;
String Pwd = datasource. selectsinglenode ("SQL _pwd"). innertext;
String DB = datasource. selectsinglenode ("SQL _db"). innertext;
Strsql = datasource. selectsinglenode ("SQL _query"). innertext;
Strconn = "Server =" + SERVER + "; uid =" + User + "; Pwd =" + PWD + "; database =" + dB;
// Read index fields and configurations
Xmlnodelist nodelist = confignode. selectsinglenode ("indexer"). selectsinglenode ("fields"). childnodes; // obtain all the subnodes of the bookstore Node
// Dictionary <string, schemafield> indexfields = new dictionary <string, schemafield> ();
Foreach (xmlnode Xn in nodelist) // traverses all subnodes
{
String fieldname = xn. selectsinglenode ("name"). innertext; // name in the Index
String dbfieldname = xn. selectsinglenode ("dbfield"). innertext; // field name in the database
Bool bstore = xn. selectsinglenode ("storened"). innertext. Equals ("1 ")? True: false; // whether to store
Bool banalyzed = xn. selectsinglenode ("analyzed"). innertext. Equals ("1 ")? True: false; // whether to perform Word Segmentation
Bool bindex = xn. selectsinglenode ("indexed"). innertext. Equals ("1 ")? True: false; // whether to index
String type = xn. selectsinglenode ("type"). innertext; // field category
String defaultvalue = xn. selectsinglenode ("defaultvalue"). innertext; // word segmentation of fields
String analyzermode = xn. selectsinglenode ("analyzermode"). innertext;
Float fboost = (float) convert. todouble (Xn. selectsinglenode ("Boost"). innertext); // weight of the field
Schemafield FD = createschemafield (fieldname, dbfieldname, defaultvalue, bindex, bstore, banalyzed, fboost, analyzermode, type );
Indexfields. Add (fieldname, FD );
}
// Default keyword query field
Defaultsearchfields = confignode. selectsinglenode ("indexer"). selectsinglenode ("defaultsearchfields"). innertext. Split (",". tochararray ());
Rambuffersizemb = int. parse (confignode. selectsinglenode ("indexer"). selectsinglenode ("men_limit"). innertext );
Return true;
}
Catch (exception E)
{
Return false;
}
}