diff --git a/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml b/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml index ccadfc6f..c98ce952 100644 --- a/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml +++ b/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml @@ -2,10 +2,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="950" d:DesignHeight="650" - MinWidth="950" MinHeight="650" - MaxWidth="950" MaxHeight="650" - Width="950" Height="650" + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="650" + MinWidth="800" MinHeight="650" + MaxWidth="800" MaxHeight="650" + Width="800" Height="650" x:Class="LibationAvalonia.Dialogs.SearchSyntaxDialog" Title="Filter Options" WindowStartupLocation="CenterOwner" @@ -16,48 +16,55 @@ RowDefinitions="Auto,Auto,*" ColumnDefinitions="Auto,Auto,Auto,Auto"> - + + + + - - - - - - - - diff --git a/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml.cs b/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml.cs index 4c3c45f9..07992c0b 100644 --- a/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml.cs +++ b/Source/LibationAvalonia/Dialogs/SearchSyntaxDialog.axaml.cs @@ -25,6 +25,9 @@ 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] " + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchNumberFields()); diff --git a/Source/LibationSearchEngine/LuceneExtensions.cs b/Source/LibationSearchEngine/LuceneExtensions.cs index 0a0c2071..20c3eaa9 100644 --- a/Source/LibationSearchEngine/LuceneExtensions.cs +++ b/Source/LibationSearchEngine/LuceneExtensions.cs @@ -37,6 +37,8 @@ namespace LibationSearchEngine internal static string ToLuceneString(this float f) => ((double)f).ToLuceneString(); internal static string ToLuceneString(this DateTime dt) => dt.ToString("yyyyMMdd") + DECIMAL_PRECISION; + internal static string ToLuceneString(this DateTime? dt) + => dt?.ToLuceneString() ?? ""; internal static string ToLuceneString(this double d) => d.ToString("0" + DECIMAL_PRECISION).PadLeft(PAD_DIGITS + DECIMAL_PRECISION.Length, '0'); } diff --git a/Source/LibationSearchEngine/SearchEngine.cs b/Source/LibationSearchEngine/SearchEngine.cs index a24266cd..693775f3 100644 --- a/Source/LibationSearchEngine/SearchEngine.cs +++ b/Source/LibationSearchEngine/SearchEngine.cs @@ -46,9 +46,6 @@ namespace LibationSearchEngine = new ReadOnlyDictionary>( new Dictionary> { - [nameof(LibraryBook.DateAdded)] = lb => lb.DateAdded.ToLuceneString(), - [nameof(Book.DatePublished)] = lb => lb.Book.DatePublished?.ToLuceneString(), - [nameof(Book.Title)] = lb => lb.Book.Title, [ALL_AUTHOR_NAMES] = lb => lb.Book.AuthorNames(), ["Author"] = lb => lb.Book.AuthorNames(), @@ -91,7 +88,13 @@ namespace LibationSearchEngine ["ProductRating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), ["Rating"] = lb => lb.Book.Rating.OverallRating.ToLuceneString(), ["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(), ["Episodes"] = lb => lb.Book.IsEpisodeChild(), ["IsEpisode"] = lb => lb.Book.IsEpisodeChild(), + + ["Absent"] = lb => lb.AbsentFromLastScan, + ["AbsentFromLastScan"] = lb => lb.AbsentFromLastScan, } ); @@ -287,7 +293,13 @@ namespace LibationSearchEngine var v2 = liberatedError(book); d.RemoveField("liberatederror"); 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) =>updateDocument( diff --git a/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.Designer.cs b/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.Designer.cs index 7600c226..f1aecf39 100644 --- a/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.Designer.cs +++ b/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.Designer.cs @@ -1,132 +1,135 @@ namespace LibationWinForms.Dialogs { - partial class SearchSyntaxDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class SearchSyntaxDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.closeBtn = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(358, 52); - this.label1.TabIndex = 0; - this.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 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 71); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(118, 65); - this.label2.TabIndex = 1; - this.label2.Text = "STRING FIELDS\r\n\r\nSearch for wizard of oz:\r\n title:oz\r\n title:\"wizard of o" + - "z\""; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(233, 71); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(195, 78); - this.label3.TabIndex = 2; - this.label3.Text = "NUMBER FIELDS\r\n\r\nFind books between 1-100 minutes long\r\n length:[1 TO 100]\r\nF" + - "ind books exactly 1 hr long\r\n length:60"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(454, 71); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(168, 52); - this.label4.TabIndex = 3; - this.label4.Text = "BOOLEAN (TRUE/FALSE) FIELDS\r\n\r\nFind books that you haven\'t rated:\r\n -IsRated"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(673, 71); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(257, 78); - this.label5.TabIndex = 4; - this.label5.Text = "ID FIELDS\r\n\r\nAlice\'s Adventures in Wonderland (ID: B015D78L0U)\r\n id:B015D78L0" + - "U\r\n\r\nAll of these are synonyms for the ID field"; - // - // closeBtn - // - this.closeBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.closeBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.closeBtn.Location = new System.Drawing.Point(890, 465); - this.closeBtn.Name = "closeBtn"; - this.closeBtn.Size = new System.Drawing.Size(75, 23); - this.closeBtn.TabIndex = 5; - this.closeBtn.Text = "Close"; - this.closeBtn.UseVisualStyleBackColor = true; - this.closeBtn.Click += new System.EventHandler(this.CloseBtn_Click); - // - // SearchSyntaxDialog - // - this.AcceptButton = this.closeBtn; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.closeBtn; - this.ClientSize = new System.Drawing.Size(977, 500); - this.Controls.Add(this.closeBtn); - this.Controls.Add(this.label5); - this.Controls.Add(this.label4); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SearchSyntaxDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Filter options"; - this.ResumeLayout(false); - this.PerformLayout(); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SearchSyntaxDialog)); + label1 = new System.Windows.Forms.Label(); + label2 = new System.Windows.Forms.Label(); + label3 = new System.Windows.Forms.Label(); + label4 = new System.Windows.Forms.Label(); + label5 = new System.Windows.Forms.Label(); + closeBtn = new System.Windows.Forms.Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new System.Drawing.Point(14, 10); + label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(410, 60); + label1.TabIndex = 0; + 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.AutoSize = true; + label2.Location = new System.Drawing.Point(14, 82); + label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(129, 75); + label2.TabIndex = 1; + label2.Text = "STRING FIELDS\r\n\r\nSearch for wizard of oz:\r\n title:oz\r\n title:\"wizard of oz\""; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new System.Drawing.Point(272, 82); + label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(224, 135); + label3.TabIndex = 2; + label3.Text = resources.GetString("label3.Text"); + // + // label4 + // + label4.AutoSize = true; + label4.Location = new System.Drawing.Point(530, 82); + label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + label4.Name = "label4"; + label4.Size = new System.Drawing.Size(187, 60); + label4.TabIndex = 3; + label4.Text = "BOOLEAN (TRUE/FALSE) FIELDS\r\n\r\nFind books that you haven't rated:\r\n -IsRated"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new System.Drawing.Point(785, 82); + label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + label5.Name = "label5"; + label5.Size = new System.Drawing.Size(278, 90); + label5.TabIndex = 4; + 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.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + closeBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + closeBtn.Location = new System.Drawing.Point(1038, 537); + closeBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + closeBtn.Name = "closeBtn"; + closeBtn.Size = new System.Drawing.Size(88, 27); + closeBtn.TabIndex = 5; + closeBtn.Text = "Close"; + closeBtn.UseVisualStyleBackColor = true; + closeBtn.Click += CloseBtn_Click; + // + // SearchSyntaxDialog + // + AcceptButton = closeBtn; + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + CancelButton = closeBtn; + ClientSize = new System.Drawing.Size(1140, 577); + Controls.Add(closeBtn); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + MaximizeBox = false; + MinimizeBox = false; + Name = "SearchSyntaxDialog"; + StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + Text = "Filter options"; + ResumeLayout(false); + PerformLayout(); + } - } + #endregion - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Button closeBtn; - } + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button closeBtn; + } } \ No newline at end of file diff --git a/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.resx b/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.resx index e8ae276d..395c5678 100644 --- a/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.resx +++ b/Source/LibationWinForms/Dialogs/SearchSyntaxDialog.resx @@ -1,5 +1,4 @@ - - + @@ -58,4 +57,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 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] + \ No newline at end of file