Browse Source

增加Filter参数

懒得勤快 4 years ago
parent
commit
1faf50923d

+ 1 - 1
Masuit.LuceneEFCore.SearchEngine/LuceneIndexSearcher.cs

@@ -148,7 +148,7 @@ namespace Masuit.LuceneEFCore.SearchEngine
                 where = where.And(m => options.Type.AssemblyQualifiedName == searcher.Doc(m.Doc).Get("Type"));
             }
 
-            var matches = searcher.Search(query, null, options.MaximumNumberOfHits, sort, true, true).ScoreDocs.Where(where.Compile());
+            var matches = searcher.Search(query, options.Filter, options.MaximumNumberOfHits, sort, true, true).ScoreDocs.Where(where.Compile());
             results.TotalHits = matches.Count();
 
             // 分页处理

+ 3 - 3
Masuit.LuceneEFCore.SearchEngine/Masuit.LuceneEFCore.SearchEngine.csproj

@@ -9,7 +9,7 @@
         <Copyright>懒得勤快</Copyright>
         <PackageProjectUrl>https://github.com/ldqk/Masuit.LuceneEFCore.SearchEngine</PackageProjectUrl>
         <PackageId>Masuit.LuceneEFCore.SearchEngine_int</PackageId>
-        <Version>1.1.4</Version>
+        <Version>1.1.5</Version>
         <Configurations>Debug;Release;String版本;Guid版本;Long版本</Configurations>
         <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
         <RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
@@ -19,8 +19,8 @@
         <IncludeSymbols>true</IncludeSymbols>
         <SymbolPackageFormat>snupkg</SymbolPackageFormat>
         <LangVersion>9</LangVersion>
-        <FileVersion>1.1.4</FileVersion>
-        <AssemblyVersion>1.1.4</AssemblyVersion>
+        <FileVersion>1.1.5</FileVersion>
+        <AssemblyVersion>1.1.5</AssemblyVersion>
         <EmbedUntrackedSources>true</EmbedUntrackedSources>
         <IncludeSymbols>true</IncludeSymbols>
         <SymbolPackageFormat>snupkg</SymbolPackageFormat>

+ 5 - 0
Masuit.LuceneEFCore.SearchEngine/SearchOptions.cs

@@ -73,6 +73,11 @@ namespace Masuit.LuceneEFCore.SearchEngine
         /// </summary>
         public float Score { get; set; } = 0.5f;
 
+        /// <summary>
+        /// 过滤条件
+        /// </summary>
+        public Filter Filter { get; set; }
+
         /// <summary>
         /// 搜索选项
         /// </summary>

+ 3 - 3
WebSearchDemo/WebSearchDemo.csproj

@@ -13,9 +13,9 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.8" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.8" />
-    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.5" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.9" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.9" />
+    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.1" />
   </ItemGroup>
 
   <ItemGroup>