Add AbsentFromLastScan (#601) LastDownloaded (#602) search

This commit is contained in:
Mbucari 2023-05-19 11:09:57 -06:00
parent 3fdfbb9e26
commit fd510861c6
6 changed files with 181 additions and 144 deletions

View File

@ -2,10 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="950" d:DesignHeight="650" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="650"
MinWidth="950" MinHeight="650" MinWidth="800" MinHeight="650"
MaxWidth="950" MaxHeight="650" MaxWidth="800" MaxHeight="650"
Width="950" Height="650" Width="800" Height="650"
x:Class="LibationAvalonia.Dialogs.SearchSyntaxDialog" x:Class="LibationAvalonia.Dialogs.SearchSyntaxDialog"
Title="Filter Options" Title="Filter Options"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
@ -16,48 +16,55 @@
RowDefinitions="Auto,Auto,*" RowDefinitions="Auto,Auto,*"
ColumnDefinitions="Auto,Auto,Auto,Auto"> ColumnDefinitions="Auto,Auto,Auto,Auto">
<TextBlock Margin="10" <Grid.Styles>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="10" />
</Style>
</Grid.Styles>
<TextBlock
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="4" Grid.ColumnSpan="4"
Text="Full Lucene query syntax is supported&#xa;Fields with similar names are synomyns (eg: Author, Authors, AuthorNames)&#xa;&#xa;TAG FORMAT: [tagName]" /> Text="Full Lucene query syntax is supported&#xa;Fields with similar names are synomyns (eg: Author, Authors, AuthorNames)&#xa;&#xa;TAG FORMAT: [tagName]" />
<TextBlock Margin="10" <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="0" Grid.Column="0"
Text="STRING FIELDS" /> Text="STRING FIELDS" />
<TextBlock Margin="10" <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Text="NUMBER FIELDS" /> Text="NUMBER FIELDS" />
<TextBlock Margin="10" <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="2"
Text="BOOLEAN (TRUE/FALSE) FIELDS" /> Text="BOOLEAN (TRUE/FALSE) FIELDS" />
<TextBlock Margin="10" <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="3" Grid.Column="3"
Text="ID FIELDS" /> Text="ID FIELDS" />
<TextBlock Margin="10" <TextBlock
Grid.Row="2" Grid.Row="2"
Grid.Column="0" Grid.Column="0"
Text="{Binding StringFields}" /> Text="{Binding StringFields}" />
<TextBlock Margin="10" <TextBlock
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Text="{Binding NumberFields}" /> Text="{Binding NumberFields}" />
<TextBlock Margin="10" <TextBlock
Grid.Row="2" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Text="{Binding BoolFields}" /> Text="{Binding BoolFields}" />
<TextBlock Margin="10" <TextBlock
Grid.Row="2" Grid.Row="2"
Grid.Column="3" Grid.Column="3"
Text="{Binding IdFields}" /> Text="{Binding IdFields}" />

View File

@ -25,6 +25,9 @@ Find books between 1-100 minutes long
length:[1 TO 100] length:[1 TO 100]
Find books exactly 1 hr long Find books exactly 1 hr long
length:60 length:60
Find books published from 2020-1-1 to
2023-12-31
datepublished:[20200101 TO 20231231]
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchNumberFields()); " + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchNumberFields());

View File

@ -37,6 +37,8 @@ namespace LibationSearchEngine
internal static string ToLuceneString(this float f) => ((double)f).ToLuceneString(); internal static string ToLuceneString(this float f) => ((double)f).ToLuceneString();
internal static string ToLuceneString(this DateTime dt) internal static string ToLuceneString(this DateTime dt)
=> dt.ToString("yyyyMMdd") + DECIMAL_PRECISION; => dt.ToString("yyyyMMdd") + DECIMAL_PRECISION;
internal static string ToLuceneString(this DateTime? dt)
=> dt?.ToLuceneString() ?? "";
internal static string ToLuceneString(this double d) internal static string ToLuceneString(this double d)
=> d.ToString("0" + DECIMAL_PRECISION).PadLeft(PAD_DIGITS + DECIMAL_PRECISION.Length, '0'); => d.ToString("0" + DECIMAL_PRECISION).PadLeft(PAD_DIGITS + DECIMAL_PRECISION.Length, '0');
} }

View File

@ -46,9 +46,6 @@ namespace LibationSearchEngine
= new ReadOnlyDictionary<string, Func<LibraryBook, string>>( = new ReadOnlyDictionary<string, Func<LibraryBook, string>>(
new Dictionary<string, Func<LibraryBook, string>> new Dictionary<string, Func<LibraryBook, string>>
{ {
[nameof(LibraryBook.DateAdded)] = lb => lb.DateAdded.ToLuceneString(),
[nameof(Book.DatePublished)] = lb => lb.Book.DatePublished?.ToLuceneString(),
[nameof(Book.Title)] = lb => lb.Book.Title, [nameof(Book.Title)] = lb => lb.Book.Title,
[ALL_AUTHOR_NAMES] = lb => lb.Book.AuthorNames(), [ALL_AUTHOR_NAMES] = lb => lb.Book.AuthorNames(),
["Author"] = lb => lb.Book.AuthorNames(), ["Author"] = lb => lb.Book.AuthorNames(),
@ -91,7 +88,13 @@ namespace LibationSearchEngine
["ProductRating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), ["ProductRating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(),
["Rating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), ["Rating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(),
["UserRating"] = lb => userOverallRating(lb.Book), ["UserRating"] = lb => userOverallRating(lb.Book),
["MyRating"] = lb => userOverallRating(lb.Book) ["MyRating"] = lb => userOverallRating(lb.Book),
[nameof(LibraryBook.DateAdded)] = lb => lb.DateAdded.ToLuceneString(),
[nameof(Book.DatePublished)] = lb => lb.Book.DatePublished?.ToLuceneString(),
["LastDownload"] = lb => lb.Book.UserDefinedItem.LastDownloaded.ToLuceneString(),
["LastDownloaded"] = lb => lb.Book.UserDefinedItem.LastDownloaded.ToLuceneString()
} }
); );
@ -127,6 +130,9 @@ namespace LibationSearchEngine
["Episode"] = lb => lb.Book.IsEpisodeChild(), ["Episode"] = lb => lb.Book.IsEpisodeChild(),
["Episodes"] = lb => lb.Book.IsEpisodeChild(), ["Episodes"] = lb => lb.Book.IsEpisodeChild(),
["IsEpisode"] = lb => lb.Book.IsEpisodeChild(), ["IsEpisode"] = lb => lb.Book.IsEpisodeChild(),
["Absent"] = lb => lb.AbsentFromLastScan,
["AbsentFromLastScan"] = lb => lb.AbsentFromLastScan,
} }
); );
@ -287,6 +293,12 @@ namespace LibationSearchEngine
var v2 = liberatedError(book); var v2 = liberatedError(book);
d.RemoveField("liberatederror"); d.RemoveField("liberatederror");
d.AddBool("LiberatedError", v2); d.AddBool("LiberatedError", v2);
var v3 = book.UserDefinedItem.LastDownloaded?.ToLuceneString() ?? "";
d.RemoveField("LastDownload");
d.AddNotAnalyzed("LastDownload", v3);
d.RemoveField("LastDownloaded");
d.AddNotAnalyzed("LastDownloaded", v3);
}); });
public void UpdateUserRatings(Book book) public void UpdateUserRatings(Book book)

View File

@ -28,96 +28,99 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SearchSyntaxDialog));
this.label2 = new System.Windows.Forms.Label(); label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); label4 = new System.Windows.Forms.Label();
this.closeBtn = new System.Windows.Forms.Button(); label5 = new System.Windows.Forms.Label();
this.SuspendLayout(); closeBtn = new System.Windows.Forms.Button();
SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9); label1.Location = new System.Drawing.Point(14, 10);
this.label1.Name = "label1"; label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Size = new System.Drawing.Size(358, 52); label1.Name = "label1";
this.label1.TabIndex = 0; label1.Size = new System.Drawing.Size(410, 60);
this.label1.Text = "Full Lucene query syntax is supported\r\nFields with similar names are synomyns (eg" + label1.TabIndex = 0;
": Author, Authors, AuthorNames)\r\n\r\nTAG FORMAT: [tagName]"; label1.Text = "Full Lucene query syntax is supported\r\nFields with similar names are synomyns (eg: Author, Authors, AuthorNames)\r\n\r\nTAG FORMAT: [tagName]";
// //
// label2 // label2
// //
this.label2.AutoSize = true; label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 71); label2.Location = new System.Drawing.Point(14, 82);
this.label2.Name = "label2"; label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Size = new System.Drawing.Size(118, 65); label2.Name = "label2";
this.label2.TabIndex = 1; label2.Size = new System.Drawing.Size(129, 75);
this.label2.Text = "STRING FIELDS\r\n\r\nSearch for wizard of oz:\r\n title:oz\r\n title:\"wizard of o" + label2.TabIndex = 1;
"z\""; label2.Text = "STRING FIELDS\r\n\r\nSearch for wizard of oz:\r\n title:oz\r\n title:\"wizard of oz\"";
// //
// label3 // label3
// //
this.label3.AutoSize = true; label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(233, 71); label3.Location = new System.Drawing.Point(272, 82);
this.label3.Name = "label3"; label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Size = new System.Drawing.Size(195, 78); label3.Name = "label3";
this.label3.TabIndex = 2; label3.Size = new System.Drawing.Size(224, 135);
this.label3.Text = "NUMBER FIELDS\r\n\r\nFind books between 1-100 minutes long\r\n length:[1 TO 100]\r\nF" + label3.TabIndex = 2;
"ind books exactly 1 hr long\r\n length:60"; label3.Text = resources.GetString("label3.Text");
// //
// label4 // label4
// //
this.label4.AutoSize = true; label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(454, 71); label4.Location = new System.Drawing.Point(530, 82);
this.label4.Name = "label4"; label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Size = new System.Drawing.Size(168, 52); label4.Name = "label4";
this.label4.TabIndex = 3; label4.Size = new System.Drawing.Size(187, 60);
this.label4.Text = "BOOLEAN (TRUE/FALSE) FIELDS\r\n\r\nFind books that you haven\'t rated:\r\n -IsRated"; label4.TabIndex = 3;
label4.Text = "BOOLEAN (TRUE/FALSE) FIELDS\r\n\r\nFind books that you haven't rated:\r\n -IsRated";
// //
// label5 // label5
// //
this.label5.AutoSize = true; label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(673, 71); label5.Location = new System.Drawing.Point(785, 82);
this.label5.Name = "label5"; label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label5.Size = new System.Drawing.Size(257, 78); label5.Name = "label5";
this.label5.TabIndex = 4; label5.Size = new System.Drawing.Size(278, 90);
this.label5.Text = "ID FIELDS\r\n\r\nAlice\'s Adventures in Wonderland (ID: B015D78L0U)\r\n id:B015D78L0" + label5.TabIndex = 4;
"U\r\n\r\nAll of these are synonyms for the ID field"; label5.Text = "ID FIELDS\r\n\r\nAlice's Adventures in Wonderland (ID: B015D78L0U)\r\n id:B015D78L0U\r\n\r\nAll of these are synonyms for the ID field";
// //
// closeBtn // closeBtn
// //
this.closeBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); closeBtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
this.closeBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; closeBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.closeBtn.Location = new System.Drawing.Point(890, 465); closeBtn.Location = new System.Drawing.Point(1038, 537);
this.closeBtn.Name = "closeBtn"; closeBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.closeBtn.Size = new System.Drawing.Size(75, 23); closeBtn.Name = "closeBtn";
this.closeBtn.TabIndex = 5; closeBtn.Size = new System.Drawing.Size(88, 27);
this.closeBtn.Text = "Close"; closeBtn.TabIndex = 5;
this.closeBtn.UseVisualStyleBackColor = true; closeBtn.Text = "Close";
this.closeBtn.Click += new System.EventHandler(this.CloseBtn_Click); closeBtn.UseVisualStyleBackColor = true;
closeBtn.Click += CloseBtn_Click;
// //
// SearchSyntaxDialog // SearchSyntaxDialog
// //
this.AcceptButton = this.closeBtn; AcceptButton = closeBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.closeBtn; CancelButton = closeBtn;
this.ClientSize = new System.Drawing.Size(977, 500); ClientSize = new System.Drawing.Size(1140, 577);
this.Controls.Add(this.closeBtn); Controls.Add(closeBtn);
this.Controls.Add(this.label5); Controls.Add(label5);
this.Controls.Add(this.label4); Controls.Add(label4);
this.Controls.Add(this.label3); Controls.Add(label3);
this.Controls.Add(this.label2); Controls.Add(label2);
this.Controls.Add(this.label1); Controls.Add(label1);
this.MaximizeBox = false; Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.MinimizeBox = false; MaximizeBox = false;
this.Name = "SearchSyntaxDialog"; MinimizeBox = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; Name = "SearchSyntaxDialog";
this.Text = "Filter options"; StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.ResumeLayout(false); Text = "Filter options";
this.PerformLayout(); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
@ -58,4 +57,15 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="label3.Text" xml:space="preserve">
<value>NUMBER FIELDS
Find books between 1-100 minutes long
length:[1 TO 100]
Find books exactly 1 hr long
length:60
Find books published from 2020-1-1 to
2023-12-31
datepublished:[20200101 TO 20231231]</value>
</data>
</root> </root>