public class IndexRepository extends Object
IndexRepository class is designed to combine multiple indexes and perform common operations on them.
Modifier and Type | Field and Description |
---|---|
Event<EventHandler<BaseIndexEventArgs>> |
ErrorHappened |
Event<EventHandler<FileIndexingEventArgs>> |
FileIndexing |
Event<EventHandler<BaseIndexEventArgs>> |
OperationFinished |
Event<EventHandler<OperationProgressEventArgs>> |
OperationProgressChanged |
Event<EventHandler<PasswordRequiredEventArgs>> |
PasswordRequired |
Constructor and Description |
---|
IndexRepository() |
Modifier and Type | Method and Description |
---|---|
void |
addToRepository(Index index)
Adds Index to repository.
|
void |
addToRepository(String indexFolder)
Adds Index to repository from disk.
|
void |
break_()
Break current asynchronous operation.
|
Index |
create()
Creates new index in memory.
|
Index |
create(IndexingSettings settings)
Creates new index in memory with selected indexing settings.
|
Index |
create(String indexFolder)
Creates new index.
|
Index |
create(String indexFolder,
IndexingSettings settings)
Creates new index with selected indexing settings.
|
protected void |
finalize()
Finalizes an instance of the
IndexRepository class. |
Index[] |
getIndexes()
Gets Indexes Array.
|
SearchResults |
search(SearchQuery query,
SearchParameters parameters)
Searches in all indexes in repository.
|
SearchResults |
search(SearchQuery query,
SearchParameters parameters,
Cancellation cancellation)
Searches in all indexes in repository.
|
SearchResults |
search(String query)
Searches in all indexes in repository with default search parameters.
|
SearchResults |
search(String query,
SearchParameters parameters)
Searches in all indexes in repository.
|
SearchResults |
search(String query,
SearchParameters parameters,
Cancellation cancellation)
Searches in all indexes in repository.
|
void |
update()
Updates all indexes in repository.
|
void |
update(Cancellation cancellation)
Updates all indexes in repository.
|
void |
updateAsync()
Updates all indexes in repository asynchronously.
|
void |
updateAsync(Cancellation cancellation)
Updates all indexes in repository asynchronously.
|
public final Event<EventHandler<BaseIndexEventArgs>> OperationFinished
public final Event<EventHandler<BaseIndexEventArgs>> ErrorHappened
public final Event<EventHandler<OperationProgressEventArgs>> OperationProgressChanged
public final Event<EventHandler<PasswordRequiredEventArgs>> PasswordRequired
public final Event<EventHandler<FileIndexingEventArgs>> FileIndexing
public final Index[] getIndexes()
Gets Indexes Array.
Value: The indexes list.protected void finalize() throws Throwable
Finalizes an instance of the IndexRepository
class.
public final Index create()
Creates new index in memory.
The following is an example of Creating new Index in memory through Index Repository.IndexRepository indexRepository = new IndexRepository(); Index index = indexRepository.Create(); // Creating index in memory
public final Index create(IndexingSettings settings)
Creates new index in memory with selected indexing settings.
The following is an example of Creating new Index in memory through Index Repository.IndexingSettings settings = new IndexingSettings() IndexRepository indexRepository = new IndexRepository(); Index index = indexRepository.Create(settings);
settings
- Indexing settings.public final Index create(String indexFolder)
Creates new index. Index folder will be cleaned before index creating.
The following is an example of Creating new Index on disk through Index Repositorystring folderForIndex = @"c:\MyIndex\"; IndexRepository indexRepository = new IndexRepository(); Index index = indexRepository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder
indexFolder
- Index Folder.public final Index create(String indexFolder, IndexingSettings settings)
Creates new index with selected indexing settings. Index folder will be cleaned before index creating.
The following is an example of Creating new Index on disk through Index Repository.IndexingSettings settings = new IndexingSettings() string folderForIndex = @"c:\MyIndex\"; IndexRepository indexRepository = new IndexRepository(settings); Index index = indexRepository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder
indexFolder
- Index Folder.settings
- Indexing settings.public final void addToRepository(Index index)
Adds Index to repository.
The following is an example of adding Index to Repository.string folderForIndex = @"c:\MyIndex\"; IndexRepository indexRepository = new IndexRepository(); Index index = indexRepository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder indexRepository.AddToRepository(index);
index
- Index for adding.public final void addToRepository(String indexFolder)
Adds Index to repository from disk.
The following is an example of adding Index to Repository.string folderForIndex = @"c:\MyIndex\"; IndexRepository indexRepository = new IndexRepository(); indexRepository.AddToRepository(folderForIndex);
indexFolder
- Folder with Index.public final void update()
Updates all indexes in repository.
The following is an example of Searching in current index.string folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder // Delete files from c:\MyDocuments\ or modify them repository.Update(); // Checking all indexed files in all indexes for deleting or modification and update indexes
public final void update(Cancellation cancellation)
Updates all indexes in repository.
The following is an example of Searching in current index.string folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder // Delete files from c:\MyDocuments\ or modify them repository.Update(); // Checking all indexed files in all indexes for deleting or modification and update indexes
cancellation
- The cancellation indicator.public final void updateAsync()
Updates all indexes in repository asynchronously.
The following is an example of Searching in current index.string folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); repository.OperationFinished += repository_OperationFinished; // subscribing on event when updatin will be finished Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder // Delete files from c:\MyDocuments\ or modify them repository.UpdateAsync(); // Checking all indexed files in all indexes for deleting or modification and update indexes
public final void updateAsync(Cancellation cancellation)
Updates all indexes in repository asynchronously.
The following is an example of Searching in current index.string folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); repository.OperationFinished += repository_OperationFinished; // subscribing on event when updatin will be finished Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder // Delete files from c:\MyDocuments\ or modify them repository.UpdateAsync(); // Checking all indexed files in all indexes for deleting or modification and update indexes
cancellation
- The cancellation indicator.public final void break_()
Break current asynchronous operation.
The following is an example of breaking asynchronous indexing operation.string folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; Index index = new Index(folderForIndex); // Creating index in c:\MyIndex\ folder index.OperationFinished += index_OperationFinished; // Subscribing on Operation Finished event index.AddToIndexAsync(folderWithDocuments); // indexing selected folder asynchronously index.Break(); // Breaking indexing
public final SearchResults search(String query)
Searches in all indexes in repository with default search parameters.
The following is an example of Searching in index repository.IndexRepository repository = new IndexRepository(); Index index1 = repository.Create(@"C:\MyIndexes\Index1\"); Index index2 = repository.Create(@"C:\MyIndexes\Index2\"); SearchResults searchResults = repository.Search("search query");
The following is an example of Searching in Index Repositorystring folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder string query = "search query"; SearchResults searchResults = repository.Search(query);
The following is an example of Regex Searching in Index Repositorystring folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder string regexQuery = "^[a-zA-Z0-9]+"; // regex in query should starts with ^ SearchResults searchResults = repository.Search(query);
The following is an example of Faceted Searching in Index Repositorystring folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder string query = "content:word1"; // SearchResults searchResults = repository.Search(query);
query
- Search query.public final SearchResults search(String query, SearchParameters parameters)
Searches in all indexes in repository.
The following is an example of Fuzzy Searching in Index Repository.string folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder SearchParameters parameters = new SearchParameters(); parameters.FuzzySearch = new FuzzySearchParameters { Enabled = true }; string query = "fuzzy search query"; SearchResults searchResults = repository.Search(query, parameters);
The following is an example of Synonym Searching in Index Repositorystring folderForIndex = @"c:\MyIndex\"; string folderWithDocuments = @"c:\MyDocuments\"; string fileWithSynonyms = @"c:\synonyms.txt"; IndexRepository repository = new IndexRepository(); Index index = repository.Create(folderForIndex); // Creating index in c:\MyIndex\ folder index.AddToIndex(folderWithDocuments); // Run indexing files from c:\MyDocuments\ folder index.LoadSynonyms(fileWithSynonyms); // load synonyms to index SearchParameters parameters = new SearchParameters(); parameters.UseSynonymSearch = true; string query = "synonym search query"; SearchResults searchResults = repository.Search(query, parameters);
query
- Search query.parameters
- Search parameters.public final SearchResults search(String query, SearchParameters parameters, Cancellation cancellation)
Searches in all indexes in repository.
query
- Search query.parameters
- Search parameters.cancellation
- The cancellation indicator.public final SearchResults search(SearchQuery query, SearchParameters parameters)
Searches in all indexes in repository.
query
- The search query.parameters
- The search parameters.public final SearchResults search(SearchQuery query, SearchParameters parameters, Cancellation cancellation)
Searches in all indexes in repository.
query
- The search query.parameters
- The search parameters.cancellation
- The cancellation indicator.Copyright © 2018. All rights reserved.