{"id":21326970,"url":"https://github.com/ssinno28/lucene.net.indexprovider","last_synced_at":"2025-10-15T08:31:24.738Z","repository":{"id":143865977,"uuid":"299118364","full_name":"ssinno28/Lucene.Net.IndexProvider","owner":"ssinno28","description":"A simple service that helps to abstract common operations when interacting with lucene.net indexes","archived":false,"fork":false,"pushed_at":"2025-01-10T15:31:58.000Z","size":79,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T01:45:42.077Z","etag":null,"topics":["csharp","lucene","lucene-net"],"latest_commit_sha":null,"homepage":"","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/ssinno28.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-27T21:00:50.000Z","updated_at":"2025-01-10T15:31:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"e4d4fce7-97be-46c1-a883-556d8f25931e","html_url":"https://github.com/ssinno28/Lucene.Net.IndexProvider","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssinno28%2FLucene.Net.IndexProvider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssinno28%2FLucene.Net.IndexProvider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssinno28%2FLucene.Net.IndexProvider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssinno28%2FLucene.Net.IndexProvider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssinno28","download_url":"https://codeload.github.com/ssinno28/Lucene.Net.IndexProvider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236598633,"owners_count":19174970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["csharp","lucene","lucene-net"],"created_at":"2024-11-21T21:12:40.415Z","updated_at":"2025-10-15T08:31:19.324Z","avatar_url":"https://github.com/ssinno28.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lucene.Net.IndexProvider\n![CI](https://github.com/ssinno28/Lucene.Net.IndexProvider/workflows/CI/badge.svg)\n\nA simple service that helps to abstract common operations when interacting with lucene.net indexes. The index provider exposes methods for managing indexes (creating, deleting and swapping) as well as CRUD operations. \n\nIt will need to be wired up with DI like so:\n\n```c#\n            services.AddLuceneProvider();\n            services.AddLuceneDocumentMapper();\n            \n            services.AddSingleton\u003cILocalIndexPathFactory, LocalIndexPathFactory\u003e();\n```\n\nIn the configure app method in the Startup.cs file you will need to set up a config for each index and add the close session middleware: \n\n```c#\nvarr indexConfigManager = serviceProvider.GetService\u003cIIndexConfigurationManager\u003e();\n            indexConfigManager.AddConfiguration(new LuceneConfig()\n            {\n                BatchSize = 500000,\n                LuceneVersion = LuceneVersion.LUCENE_48,\n                Indexes = new List\u003cType\u003e()\n                {\n                    nameof(BlogPost),\n                }\n            });\n\n            app.UseMiddleware\u003cCloseIndexSessionMiddleware\u003e();\n```\n\nYou'll also want to setup a LocalIndexPathFactory class that implements `ILocalIndexPathFactory` and add it as an injected service.\n\n```c#\n    public class LocalIndexPathFactory : ILocalIndexPathFactory\n    {\n        private readonly IWebHostEnvironment _webHostEnvironment;\n\n        public LocalIndexPathFactory(IWebHostEnvironment webHostEnvironment)\n        {\n            _webHostEnvironment = webHostEnvironment;\n        }\n\n        public string GetLocalIndexPath()\n        {\n            return Path.Combine(_webHostEnvironment.ContentRootPath, \"App_Data\", \"index\");\n        }\n    }\n```\n\nIn order to query against the index there is a fluent API that allows you to pass in as many query types you want:\n\n```c#\n var listResult =\n                await _indexProvider.Search()\n                    .Must(() =\u003e new TermQuery(new Term(\"Tags.Name\", \"my-test-tag\")))\n                    .ListResult\u003cBlogPost\u003e();\n```\n\nYou can concatenate as many Must, Should and MustNot queries as you would like and call ListResults at the end to get the items and count.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssinno28%2Flucene.net.indexprovider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssinno28%2Flucene.net.indexprovider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssinno28%2Flucene.net.indexprovider/lists"}