add library search buttons (#177)
This commit is contained in:
@@ -11,6 +11,9 @@ using ErsatzTV.Core.Interfaces.Search;
|
||||
using ErsatzTV.Core.Search;
|
||||
using LanguageExt;
|
||||
using LanguageExt.UnsafeValueAccess;
|
||||
using Lucene.Net.Analysis;
|
||||
using Lucene.Net.Analysis.Core;
|
||||
using Lucene.Net.Analysis.Miscellaneous;
|
||||
using Lucene.Net.Analysis.Standard;
|
||||
using Lucene.Net.Documents;
|
||||
using Lucene.Net.Index;
|
||||
@@ -62,7 +65,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
_cultureInfos = CultureInfo.GetCultures(CultureTypes.NeutralCultures).ToList();
|
||||
}
|
||||
|
||||
public int Version => 7;
|
||||
public int Version => 8;
|
||||
|
||||
public Task<bool> Initialize(ILocalFileSystem localFileSystem)
|
||||
{
|
||||
@@ -155,9 +158,14 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
var searcher = new IndexSearcher(reader);
|
||||
int hitsLimit = limit == 0 ? searcher.IndexReader.MaxDoc : skip + limit;
|
||||
using var analyzer = new StandardAnalyzer(AppLuceneVersion);
|
||||
var customAnalyzers = new Dictionary<string, Analyzer>
|
||||
{
|
||||
{ LibraryNameField, new KeywordAnalyzer() }
|
||||
};
|
||||
using var analyzerWrapper = new PerFieldAnalyzerWrapper(analyzer, customAnalyzers);
|
||||
QueryParser parser = !string.IsNullOrWhiteSpace(searchField)
|
||||
? new QueryParser(AppLuceneVersion, searchField, analyzer)
|
||||
: new MultiFieldQueryParser(AppLuceneVersion, new[] { TitleField }, analyzer);
|
||||
? new QueryParser(AppLuceneVersion, searchField, analyzerWrapper)
|
||||
: new MultiFieldQueryParser(AppLuceneVersion, new[] { TitleField }, analyzerWrapper);
|
||||
parser.AllowLeadingWildcard = true;
|
||||
Query query = ParseQuery(searchQuery, parser);
|
||||
var filter = new DuplicateFilter(TitleAndYearField);
|
||||
@@ -251,7 +259,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
new StringField(TypeField, MovieType, Field.Store.NO),
|
||||
new TextField(TitleField, metadata.Title, Field.Store.NO),
|
||||
new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO),
|
||||
new TextField(LibraryNameField, movie.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(LibraryNameField, movie.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(TitleAndYearField, GetTitleAndYear(metadata), Field.Store.NO),
|
||||
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
|
||||
};
|
||||
@@ -338,7 +346,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
new StringField(TypeField, ShowType, Field.Store.NO),
|
||||
new TextField(TitleField, metadata.Title, Field.Store.NO),
|
||||
new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO),
|
||||
new TextField(LibraryNameField, show.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(LibraryNameField, show.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(TitleAndYearField, GetTitleAndYear(metadata), Field.Store.NO),
|
||||
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
|
||||
};
|
||||
@@ -418,7 +426,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
new StringField(TypeField, ArtistType, Field.Store.NO),
|
||||
new TextField(TitleField, metadata.Title, Field.Store.NO),
|
||||
new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO),
|
||||
new TextField(LibraryNameField, artist.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(LibraryNameField, artist.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(TitleAndYearField, GetTitleAndYear(metadata), Field.Store.NO),
|
||||
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
|
||||
};
|
||||
@@ -479,7 +487,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
new StringField(TypeField, MusicVideoType, Field.Store.NO),
|
||||
new TextField(TitleField, metadata.Title, Field.Store.NO),
|
||||
new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO),
|
||||
new TextField(LibraryNameField, musicVideo.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(LibraryNameField, musicVideo.LibraryPath.Library.Name, Field.Store.NO),
|
||||
new StringField(TitleAndYearField, GetTitleAndYear(metadata), Field.Store.NO),
|
||||
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
|
||||
};
|
||||
@@ -543,7 +551,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
}
|
||||
|
||||
private static string GetTitleAndYear(Metadata metadata) =>
|
||||
$"{metadata.Title}_{metadata.Year}";
|
||||
$"{metadata.Title}_{metadata.Year}".ToLowerInvariant();
|
||||
|
||||
private static string GetJumpLetter(Metadata metadata)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<col/>
|
||||
<col/>
|
||||
<col/>
|
||||
<col style="width: 180px;"/>
|
||||
<col style="width: 240px;"/>
|
||||
</ColGroup>
|
||||
<HeaderContent>
|
||||
<MudTh>Library Kind</MudTh>
|
||||
@@ -60,6 +60,11 @@
|
||||
</MudIconButton>
|
||||
</MudTooltip>
|
||||
}
|
||||
<MudTooltip Text="Search Library">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Search"
|
||||
Link="@($"/search?query=library_name%3a%22{Uri.EscapeDataString(context.Name)}%22")">
|
||||
</MudIconButton>
|
||||
</MudTooltip>
|
||||
@if (context is LocalLibraryViewModel)
|
||||
{
|
||||
<MudTooltip Text="Edit Library">
|
||||
|
||||
Reference in New Issue
Block a user