{"id":37034755,"url":"https://github.com/dealloc/lucent","last_synced_at":"2026-01-14T04:04:26.603Z","repository":{"id":318959935,"uuid":"1076929254","full_name":"dealloc/lucent","owner":"dealloc","description":"Minimalistic wrapper around Lucene.NET for idiomatic configuration and service management","archived":false,"fork":false,"pushed_at":"2025-10-16T15:14:13.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-28T19:47:19.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://lucent.dealloc.be/README.html","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dealloc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["dealloc"],"buy_me_a_coffee":"dealloc"}},"created_at":"2025-10-15T14:36:00.000Z","updated_at":"2025-10-16T15:13:22.000Z","dependencies_parsed_at":"2025-10-17T12:26:48.383Z","dependency_job_id":"1c16c265-bd55-4d5c-bbde-18961b1967ef","html_url":"https://github.com/dealloc/lucent","commit_stats":null,"previous_names":["dealloc/lucent"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dealloc/lucent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dealloc%2Flucent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dealloc%2Flucent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dealloc%2Flucent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dealloc%2Flucent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dealloc","download_url":"https://codeload.github.com/dealloc/lucent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dealloc%2Flucent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T04:04:25.718Z","updated_at":"2026-01-14T04:04:26.598Z","avatar_url":"https://github.com/dealloc.png","language":"C#","funding_links":["https://github.com/sponsors/dealloc","https://buymeacoffee.com/dealloc"],"categories":[],"sub_categories":[],"readme":"# Lucent\n\nA lean, minimalistic .NET library that provides idiomatic integration of Lucene.NET with dependency injection and modern .NET configuration patterns.\n\n## Overview\n\nLucent is designed to bring Lucene.NET closer to idiomatic .NET best practices while maintaining direct access to the underlying Lucene.NET types and APIs. Unlike heavier abstraction layers, Lucent focuses on providing just what you need: service container integration, configuration management, and lifecycle handling.\n\n## Key Features\n\n- **Minimal Abstraction**: Direct access to Lucene.NET types and APIs\n- **Service Container Integration**: Native support for .NET dependency injection\n- **Idiomatic Configuration**: Leverage `IConfiguration` and options patterns\n- **Lifecycle Management**: Proper disposal and resource management\n- **Lean Design**: No unnecessary wrappers or query builders\n\n## Philosophy\n\nLucent takes a different approach compared to libraries like Examine. While Examine provides extensive abstractions and query builders, Lucent maintains the full power and flexibility of Lucene.NET while simply making it easier to use in modern .NET applications.\n\nIf you require more high-level abstractions, fluent query builders, we recommend checking out the excellent [Examine](https://github.com/Shazwazza/Examine) library.\n\n## Comparison with Examine\n\n| Feature | Lucent | Examine |\n|---------|---------|---------|\n| Abstraction Level | Minimal | High |\n| Query Building | Direct Lucene.NET | Fluent API |\n| Learning Curve | Requires Lucene.NET knowledge | Examine-specific |\n| Flexibility | Full Lucene.NET power | Limited to abstractions |\n| Use Case | Lucene users | Quick implementation |\n\n## Requirements\n\n- .NET 9.0 or later\n- Lucene.NET 4.8-beta00017 or later\n\n## Installation\n\n```bash\ndotnet add package Lucent\n```\n\n## Quick Start\n\n```csharp\nusing Lucene.Net.Documents;\nusing Lucene.Net.Documents.Extensions;\nusing Lucene.Net.Index;\nusing Lucene.Net.Search;\nusing Lucent.Configuration;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nvar builder = Host.CreateApplicationBuilder(args);\n\n// Register Lucent index with default configuration (uses RAMDirectory)\nbuilder.Services.AddLucentIndex();\n\nvar app = builder.Build();\n\nusing var scope = app.Services.CreateScope();\n\n// Get the IndexWriter and add a document\nusing var writer = scope.ServiceProvider.GetRequiredService\u003cIndexWriter\u003e();\nvar document = new Document();\ndocument.AddStringField(\"name\", \"brown fox\", Field.Store.YES);\nwriter.AddDocument(document);\nwriter.Commit();\n\n// Search the index\nvar searcher = scope.ServiceProvider.GetRequiredService\u003cIndexSearcher\u003e();\nvar query = new PhraseQuery { new Term(\"name\", \"brown fox\") };\nvar hits = searcher.Search(query, 10);\n\nConsole.WriteLine($\"Hits: {hits.TotalHits}\");\n```\n\n## Usage\n\n### Basic Index Configuration\n\nBy default, Lucent uses an in-memory `RAMDirectory` and `StandardAnalyzer`. For production use, configure a persistent directory:\n\n```csharp\nusing Lucene.Net.Store;\nusing Lucent.Configuration;\n\nbuilder.Services.AddLucentIndex();\n\n// Configure to use a file-based directory\nbuilder.Services.Configure\u003cIndexConfiguration\u003e(options =\u003e\n    options.Directory = new MMapDirectory(new DirectoryInfo(\"index\")));\n```\n\n### Custom Analyzer\n\nConfigure a custom analyzer for your index:\n\n```csharp\nusing Lucene.Net.Analysis.En;\nusing Lucent.Configuration;\n\nbuilder.Services.Configure\u003cIndexConfiguration\u003e(options =\u003e\n{\n    options.Directory = new MMapDirectory(new DirectoryInfo(\"index\"));\n    options.Analyzer = new EnglishAnalyzer(options.Version);\n});\n```\n\n### Multiple Indices\n\nLucent supports registering multiple named indices using keyed services:\n\n```csharp\nusing Lucene.Net.Index;\nusing Lucene.Net.Search;\nusing Microsoft.Extensions.DependencyInjection;\n\n// Register multiple indices\nbuilder.Services.AddNamedLucentIndex(\"products\");\nbuilder.Services.AddNamedLucentIndex(\"customers\");\n\n// Configure each index separately\nbuilder.Services.Configure\u003cIndexConfiguration\u003e(\"products\", options =\u003e\n    options.Directory = new MMapDirectory(new DirectoryInfo(\"products-index\")));\n\nbuilder.Services.Configure\u003cIndexConfiguration\u003e(\"customers\", options =\u003e\n    options.Directory = new MMapDirectory(new DirectoryInfo(\"customers-index\")));\n\n// Resolve using keyed services\nusing var scope = app.Services.CreateScope();\nvar productsWriter = scope.ServiceProvider.GetRequiredKeyedService\u003cIndexWriter\u003e(\"products\");\nvar customersWriter = scope.ServiceProvider.GetRequiredKeyedService\u003cIndexWriter\u003e(\"customers\");\nvar productsSearcher = scope.ServiceProvider.GetRequiredKeyedService\u003cIndexSearcher\u003e(\"products\");\n```\n\n### Available Services\n\nWhen you call `AddLucentIndex()` or `AddNamedLucentIndex()`, the following services are registered:\n\n- **`IndexWriter`** (scoped) - For adding, updating, and deleting documents\n- **`IndexReader`** (scoped) - For reading the index\n- **`IndexSearcher`** (scoped) - For searching the index\n- **`ITaxonomyWriter`** (scoped) - For writing facet taxonomies (when FacetsDirectory is configured)\n- **`TaxonomyReader`** (scoped) - For reading facet taxonomies (when FacetsDirectory is configured)\n\n### Configuration Options\n\nThe `IndexConfiguration` class supports the following options:\n\n```csharp\npublic class IndexConfiguration\n{\n    // The Lucene version to use (default: LUCENE_48)\n    public LuceneVersion Version { get; set; }\n\n    // The directory where the index is stored (default: RAMDirectory)\n    public Directory Directory { get; set; }\n\n    // Optional: The directory for storing facet taxonomies\n    public Directory FacetsDirectory { get; set; }\n\n    // The analyzer to use for text processing (default: StandardAnalyzer)\n    public Analyzer Analyzer { get; set; }\n\n    // Optional: Custom IndexWriterConfig (auto-created if null)\n    public IndexWriterConfig IndexWriterConfig { get; set; }\n\n    // Optional: Configuration for faceted search\n    public FacetsConfig FacetsConfig { get; set; }\n}\n```\n\n### Faceted Search\n\nLucent supports Lucene.NET's faceted search capabilities through taxonomy-based faceting. This enables features like filtering by categories, brands, or other hierarchical dimensions.\n\n#### Basic Facets Setup\n\nConfigure facets by setting a `FacetsDirectory` and optionally a `FacetsConfig`:\n\n```csharp\nusing Lucene.Net.Facet;\nusing Lucene.Net.Store;\nusing Lucent.Configuration;\n\nbuilder.Services.AddLucentIndex();\nbuilder.Services.Configure\u003cIndexConfiguration\u003e(options =\u003e\n{\n    options.Directory = new MMapDirectory(new DirectoryInfo(\"index\"));\n    options.FacetsDirectory = new MMapDirectory(new DirectoryInfo(\"facets\"));\n    options.FacetsConfig = new FacetsConfig();\n});\n```\n\n#### Indexing with Facets\n\nWhen facets are configured, inject `ITaxonomyWriter` along with `IndexWriter`:\n\n```csharp\nusing Lucene.Net.Documents;\nusing Lucene.Net.Documents.Extensions;\nusing Lucene.Net.Facet;\nusing Lucene.Net.Facet.Taxonomy;\nusing Lucene.Net.Index;\n\nusing var writer = scope.ServiceProvider.GetRequiredService\u003cIndexWriter\u003e();\nusing var taxonomyWriter = scope.ServiceProvider.GetRequiredService\u003cITaxonomyWriter\u003e();\nvar facetsConfig = scope.ServiceProvider\n    .GetRequiredService\u003cIOptions\u003cIndexConfiguration\u003e\u003e().Value.FacetsConfig;\n\nvar document = new Document();\ndocument.AddStringField(\"name\", \"MacBook Pro\", Field.Store.YES);\n\n// Add facet fields\ndocument.AddFacetField(\"category\", \"Electronics\");\ndocument.AddFacetField(\"brand\", \"Apple\");\n\n// Build the document with facets\nvar builtDoc = facetsConfig.Build(taxonomyWriter, document);\nwriter.AddDocument(builtDoc);\n\nwriter.Commit();\ntaxonomyWriter.Commit();\n```\n\n#### Searching with Facets\n\nUse `FacetsCollector` and `TaxonomyReader` to retrieve facet counts:\n\n```csharp\nusing Lucene.Net.Facet;\nusing Lucene.Net.Facet.Taxonomy;\nusing Lucene.Net.Search;\n\nvar searcher = scope.ServiceProvider.GetRequiredService\u003cIndexSearcher\u003e();\nvar taxonomyReader = scope.ServiceProvider.GetRequiredService\u003cTaxonomyReader\u003e();\nvar facetsConfig = scope.ServiceProvider\n    .GetRequiredService\u003cIOptions\u003cIndexConfiguration\u003e\u003e().Value.FacetsConfig;\n\nvar query = new MatchAllDocsQuery();\nvar facetsCollector = new FacetsCollector();\n\nFacetsCollector.Search(searcher, query, 10, facetsCollector);\n\n// Get facet counts\nvar facets = new FastTaxonomyFacetCounts(taxonomyReader, facetsConfig, facetsCollector);\n\nvar categoryFacets = facets.GetTopChildren(10, \"category\");\nforeach (var facet in categoryFacets.LabelValues)\n{\n    Console.WriteLine($\"{facet.Label}: {facet.Value}\");\n}\n```\n\n#### Drill-Down Queries\n\nFilter results by facet values using `DrillDownQuery`:\n\n```csharp\nusing Lucene.Net.Facet;\n\nvar drillDownQuery = new DrillDownQuery(facetsConfig);\ndrillDownQuery.Add(\"category\", \"Electronics\");\n\nvar electronicsCollector = new FacetsCollector();\nvar topDocs = FacetsCollector.Search(searcher, drillDownQuery, 10, electronicsCollector);\n\n// Get facet counts for the filtered results\nvar electronicsFacets = new FastTaxonomyFacetCounts(\n    taxonomyReader, facetsConfig, electronicsCollector);\n```\n\nFor a complete example, see the [Facets sample](samples/Lucent.Samples.Facets).\n\n### Working with ASP.NET Core\n\nIntegrate Lucent in your ASP.NET Core application:\n\n```csharp\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddLucentIndex();\nbuilder.Services.Configure\u003cIndexConfiguration\u003e(\n    builder.Configuration.GetSection(\"Lucent\"));\n\n// In your controllers or services, inject the required Lucene services\npublic class SearchController : ControllerBase\n{\n    private readonly IndexSearcher _searcher;\n\n    public SearchController(IndexSearcher searcher)\n    {\n        _searcher = searcher;\n    }\n\n    [HttpGet]\n    public IActionResult Search(string query)\n    {\n        var parsedQuery = new TermQuery(new Term(\"content\", query));\n        var results = _searcher.Search(parsedQuery, 10);\n        return Ok(results);\n    }\n}\n```\n\n## Contributing\n\nContributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) and submit pull requests to the `develop` branch.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.\n\n## Acknowledgments\n\n- Built on top of the [Lucene.NET](https://lucenenet.apache.org/) library\n- Inspired by the simplicity needs not met by existing abstraction layers","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdealloc%2Flucent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdealloc%2Flucent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdealloc%2Flucent/lists"}