Skip to content

Commit

Permalink
updating configs to work for index string names
Browse files Browse the repository at this point in the history
  • Loading branch information
ssinno28 committed Nov 21, 2023
1 parent 8fbbad5 commit 9612673
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Lucene.Net.IndexProvider.Tests/IndexProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public async Task InitializeAsync()
var sessionManager = _serviceProvider.GetService<IIndexSessionManager>();
configurationManager.AddConfiguration(new LuceneConfig()
{
IndexTypes = new[] { typeof(BlogPost) },
Indexes = new[] { nameof(BlogPost) },
BatchSize = 50000,
LuceneVersion = LuceneVersion.LUCENE_48
});
Expand Down
2 changes: 1 addition & 1 deletion Lucene.Net.IndexProvider/Lucene.Net.IndexProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<PropertyGroup>
<Version>1.0.22</Version>
<Version>1.0.23</Version>
<RepositoryUrl>https://github.com/ssinno28/Lucene.Net.IndexProvider</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Description>A simple service that helps to abstract common operations when interacting with lucene.net indexes.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void AddConfiguration(LuceneConfig config)

public LuceneConfig GetConfiguration(string indexName)
{
var config = Configurations.First(x => x.IndexTypes.Any(t => t.Name.Equals(indexName)));
var config = Configurations.First(x => x.Indexes.Any(t => t.Equals(indexName)));
return config;
}
}
7 changes: 3 additions & 4 deletions Lucene.Net.IndexProvider/Managers/IndexSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public IndexWriter GetSessionFrom(string indexName)
{
if (!ContextSessions.TryGetValue(indexName, out var context))
{
var config =
_configurationManager.Configurations.First(x => x.IndexTypes.Any(t => t.Name.Equals(indexName)));
var config = _configurationManager.GetConfiguration(indexName);

var analyzer = new StandardAnalyzer(config.LuceneVersion);
var indexConfig = new IndexWriterConfig(config.LuceneVersion, analyzer);
Expand All @@ -55,8 +54,8 @@ private FSDirectory GetDirectory(string indexName)

public IndexWriter GetTransientSession(string indexName)
{
var config =
_configurationManager.Configurations.First(x => x.IndexTypes.Any(t => t.Name.Equals(indexName)));
var config = _configurationManager.GetConfiguration(indexName);

var analyzer = new StandardAnalyzer(config.LuceneVersion);
var indexConfig = new IndexWriterConfig(config.LuceneVersion, analyzer);
var writer = new IndexWriter(GetDirectory(indexName), indexConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ async Task InvokeAsync(HttpContext context)
{
foreach (var config in _configurationManager.Configurations)
{
foreach (var configIndexType in config.IndexTypes)
foreach (var index in config.Indexes)
{
_sessionManager.CloseSessionOn(configIndexType.Name);
_sessionManager.CloseSessionOn(index);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lucene.Net.IndexProvider/Models/LuceneConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class LuceneConfig
{
public LuceneVersion LuceneVersion { get; set; }
public int BatchSize { get; set; }
public IList<Type> IndexTypes { get; set; }
public IList<string> Indexes { get; set; }
}
}

0 comments on commit 9612673

Please sign in to comment.