public DataTable GetAllDocument(string schemaName, string indexName) { if (string.IsNullOrEmpty(schemaName)) { throw new NullReferenceException("Şema adı boş geçilemez"); } if (!ExistSchema(schemaName)) { throw new NullReferenceException("Şema bulunamadı"); } if (string.IsNullOrEmpty(indexName)) { throw new NullReferenceException("Index adı boş geçilemez"); } if (!_indexCollection[schemaName].ContainsKey(indexName)) { throw new NullReferenceException("Index bulunamadı"); } var docIndex = new LuceneDocument(Path.Combine(_dataPath, _indexCollection[schemaName][indexName])); var result = docIndex.GetAllDocuments(); docIndex.Dispose(); return(result); }
private void LoadIndexes(LuceneSchema schema) { var docIndex = new LuceneDocument(Path.Combine(_indexPath, schema.Id)); _indexCollection.Remove(schema.Name); var table = docIndex.GetAllDocuments(); if (table == null) { return; } var indexList = new Dictionary <string, string>(); foreach (DataRow row in table.Rows) { indexList.Add(row["name"].ToString(), row["id"].ToString()); } _indexCollection.Add(schema.Name, indexList); docIndex.Dispose(); }
public void Index(string schemaName, DataTable table) { if (string.IsNullOrEmpty(schemaName)) { throw new NullReferenceException("Şema adı boş geçilemez"); } if (!ExistSchema(schemaName)) { throw new NullReferenceException("Şema bulunamadı"); } var docIndex = new LuceneDocument(Path.Combine(_indexPath, _luceneSchemaCollection[schemaName].Id)); var indexControl = false; if (!_indexCollection.ContainsKey(schemaName)) { indexControl = false; } else if (!_indexCollection[schemaName].ContainsKey(table.TableName)) { indexControl = false; } if (!indexControl) { var t = new DataTable(_schemaDocName.Trim()); t.Columns.Add("name"); t.Columns.Add("id"); var row = t.NewRow(); row["name"] = table.TableName; row["id"] = Guid.NewGuid(); t.Rows.Add(row); docIndex.AddToIndex(t); docIndex.Dispose(); LoadSchema(); } docIndex = new LuceneDocument(Path.Combine(_dataPath, _indexCollection[schemaName][table.TableName])); docIndex.AddToIndex(table); docIndex.Dispose(); docIndex = null; }
private void init() { CheckDirectory(_rootPath); CheckDirectory(_schemaPath); _luceneDocumentCollection = new LuceneDocumentCollection(); _luceneSchemaCollection = new LuceneSchemaCollection(); _indexCollection = new Dictionary <string, Dictionary <string, string> >(); var docSchema = new LuceneDocument(_schemaPath); _luceneDocumentCollection.Add(_schemaDocName, docSchema); LoadSchema(); }