/// <summary> /// Load the document store from workspace volume /// </summary> /// <param name="workspaceFolder">Workspace location</param> public DocumentStoreModel LoadStore(string workspaceFolder) { if (_storeIndex == null) { this._storeIndex = new DocumentIndex(workspaceFolder); } DocumentStoreModel docStore = new DocumentStoreModel(); documentLocationFile = Path.Combine(workspaceFolder, "DocumentStore.lucy"); documentLocationDocFile = Path.Combine(workspaceFolder, "DocumentStoreDoc.lucy"); if (File.Exists(documentLocationFile)) { using (Stream stream = File.Open(documentLocationFile, FileMode.Open)) { docStore = (DocumentStoreModel)serializer.Deserialize(stream); } using (Stream stream = File.Open(documentLocationDocFile, FileMode.Open)) { _storeIndex.DocumentIdentity = (List<DocumentIdentity>)serializerIndex.Deserialize(stream); } } this._storeIndex.PluginManager = new PluginManager(); _storeIndex.PluginManager.Load(); return docStore; }
public void TestAddDocumentToIndex() { DocumentIndex index = new DocumentIndex(IndexDir); index.Add(document1A); Assert.IsTrue(index.DocumentIdentity.Count == 1, "One document added"); }
public void TestIndexUnicity() { DocumentIdentity document1ABis = new DocumentIdentity(); document1ABis.Checksum = document1A.Checksum; document1ABis.FilePath = document1A.FilePath; document1ABis.DocumentID = document1A.DocumentID; document1ABis.State = IndexationStates.Undefined; DocumentIndex index = new DocumentIndex(IndexDir); index.Add(document1A); index.Add(document1ABis); Assert.IsTrue(index.DocumentIdentity.Count == 1, "One different document added"); document1ABis.State = IndexationStates.NotIndexed; index.Add(document1ABis); Assert.IsTrue(index.DocumentIdentity.Count == 1, "One different document added"); }
public void TestScan() { DocumentIndex index = new DocumentIndex(IndexDir); PluginManager plugin = new PluginManager(); plugin.Load(); index.PluginManager = plugin; index.Add(document1A); index.Scan(); foreach (var doc in index.DocumentIdentity) { Assert.IsTrue(doc.State == IndexationStates.Indexed, "All documents must be index after a scan"); } }
public void TestQuery() { DocumentIndex index = new DocumentIndex(IndexDir); PluginManager plugin = new PluginManager(); plugin.Load(); index.PluginManager = plugin; index.Add(document1A); index.Scan(); var result = index.Search( String.Format("Name:\"{0}\"", Path.GetFileNameWithoutExtension(document1A.FilePath))); Assert.IsTrue(result.Count() == 1, "Should found 1 doc, found = {0}", result.Count()); }