https://github.com/lofcz/fastdex
Fast inverted index powered by Lucene.NET
https://github.com/lofcz/fastdex
fulltext-search index inverted-index lucene lucene-net
Last synced: 17 days ago
JSON representation
Fast inverted index powered by Lucene.NET
- Host: GitHub
- URL: https://github.com/lofcz/fastdex
- Owner: lofcz
- License: mit
- Created: 2024-10-05T09:51:34.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-02T07:06:22.000Z (11 months ago)
- Last Synced: 2025-01-03T02:27:26.900Z (9 months ago)
- Topics: fulltext-search, index, inverted-index, lucene, lucene-net
- Language: C#
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/FastDex)
# FastDex
Fast inverted index powered by [Lucene.NET](https://github.com/apache/lucenenet).
## Getting Started
Install the library:
```
Install-Package FastDex
```Create an index, by default file storage is used:
```cs
// creates directory "myindex" if it doesn't exist, rebuilds stale index if necessary
InvertedIndex index = new InvertedIndex("myindex");
```Add some documents:
```cs
List sourceDocuments =
[
new IndexDocument { Content = "public v[oi]d Method() ú", Id = "1" },
new IndexDocument { Content = "int x = 5 * 3; ú", Id = "2" },
new IndexDocument { Content = "if (condition) { }", Id = "3" },
];/* removes any other documents currently indexed, updates the existing documents if content changed
can report progress */
index.SynchronizeIndex(sourceDocuments);
```Alternatively, add/update and delete documents manually:
```cs
index.IndexDocument("document content", "1"); // add/update
index.DeleteDocument("1");
```Finally, search the index:
```cs
// supported features: case (in)sensitivity, whole words search, paging
List results = index.Search("x =");
```## Gotchas
- `Dispose()` the index once it's no longer needed.
- The index can be searched from multiple threads simultaneously (near realtime).
- The index can be opened only once, use it as a static resource and dispose of it when closing the application, eg. `lifetime.ApplicationStopping.Register(() => { myindex.Dispose(); });` in .NET Core.