mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-02-15 08:33:45 -05:00
45 lines
1003 B
C#
45 lines
1003 B
C#
using DataLayer;
|
|
using LibationFileManager;
|
|
using LibationSearchEngine;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ApplicationServices;
|
|
|
|
/// <summary>
|
|
/// A temporary search engine created in InProgress/TempSearchEngine
|
|
/// Used for Trash Bin searches to avoid interfering with the main search engine
|
|
/// </summary>
|
|
public class TempSearchEngine : ISearchEngine
|
|
{
|
|
public static string SearchEnginePath { get; }
|
|
= System.IO.Path.Combine(Configuration.Instance.InProgress, nameof(TempSearchEngine));
|
|
private SearchEngine SearchEngine { get; } = new SearchEngine(SearchEnginePath);
|
|
|
|
public bool ReindexSearchEngine(IEnumerable<LibraryBook> books)
|
|
{
|
|
try
|
|
{
|
|
SearchEngine.CreateNewIndex(books, overwrite: true);
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public SearchResultSet? GetSearchResultSet(string? searchString)
|
|
{
|
|
if (string.IsNullOrEmpty(searchString))
|
|
return null;
|
|
|
|
try
|
|
{
|
|
return SearchEngine.Search(searchString);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|