public static GetAnalyzerForName ( string analyzerName ) : |
||
analyzerName | string | |
return |
private QueryParser CreateQueryParser(string analyzerName) { analyzer = Analyzing.GetAnalyzerForName(analyzerName); if (null == analyzer) { _luke.ErrorMessage(string.Format(_luke.resources.GetString("AnalyzerNotFound"), analyzerName)); analyzer = stdAnalyzer; } string defField = (string)comboFields.SelectedItem; if (defField == null || defField == string.Empty) { defField = _indexFields[0]; comboFields.SelectedItem = analyzerName; } return(new QueryParser(Luke.LUCENE_VERSION, defField, analyzer)); }
private void EditAdd() { Document doc = new Document(); Analyzer a; string analyzerName = (string)cmbAnalyzers.SelectedItem; if (null == analyzerName || analyzerName == string.Empty) { analyzerName = "Lucene.Net.Analysis.Standard.StandardAnalyzer"; cmbAnalyzers.SelectedItem = analyzerName; a = new StandardAnalyzer(Luke.LUCENE_VERSION); } else { a = Analyzing.GetAnalyzerForName(analyzerName); if (null == a) { luke.ShowStatus(string.Format(resources.GetString("AnalyzerNotFound"), analyzerName)); a = new StandardAnalyzer(Luke.LUCENE_VERSION); } } foreach (Field f in fields) { doc.Add(f); } IndexWriter writer = null; Directory dir = luke.IndexReader.Directory(); try { luke.IndexReader.Close(); writer = new IndexWriter(dir, a, IndexWriter.MaxFieldLength.UNLIMITED); writer.AddDocument(doc); } catch (Exception exc) { luke.ErrorMessage(exc.Message); } finally { try { if (writer != null) { writer.Commit(); writer.Close(); } } catch (Exception) { } try { luke.IndexReader = IndexReader.Open(dir, true); } catch (Exception e2) { luke.ErrorMessage(e2.Message); } } }