From 56c89711b6e6d60d143b162068fdb774857b7052 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 21 Dec 2023 10:11:53 -0700 Subject: [PATCH] Adds Id query --- .../Examine.Lucene/Search/FluentApiTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs b/src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs index f7f9df12..ecd8550d 100644 --- a/src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs +++ b/src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs @@ -2200,6 +2200,34 @@ public void Category() } } + [Test] + public void By_Id() + { + var analyzer = new StandardAnalyzer(LuceneInfo.CurrentVersion); + using (var luceneDir = new RandomIdRAMDirectory()) + using (var indexer = GetTestIndex(luceneDir, analyzer)) + { + indexer.IndexItems(new[] { + ValueSet.FromObject(1.ToString(), "content", + new { Content = "hello world", Type = "type1" }), + ValueSet.FromObject(2.ToString(), "content", + new { Content = "hello something or other", Type = "type1" }), + ValueSet.FromObject(3.ToString(), "content", + new { Content = "hello you guys", Type = "type1" }) + }); + + var searcher = indexer.Searcher; + + var query = searcher.CreateQuery().Id(2.ToString()); + Console.WriteLine(query); + + var results = query.Execute(); + + //Assert + Assert.AreEqual(1, results.TotalItemCount); + } + } + [Ignore("This test needs to be updated to ensure that searching calls GetFieldInternalQuery with useQueryParser = false, see https://github.com/Shazwazza/Examine/issues/335#issuecomment-1834677581")] [Test] public void Query_With_Category_Multi_Threaded()