Преглед изворни кода

修复索引删除失败的问题

懒得勤快 пре 3 година
родитељ
комит
a5ce3b2c35

+ 14 - 15
Masuit.LuceneEFCore.SearchEngine/LuceneIndexableBaseEntity.cs

@@ -71,23 +71,18 @@ namespace Masuit.LuceneEFCore.SearchEngine
                     continue;
                 }
 
+                //1. 该处修复用IndexId去删除索引无效的问题
+                //2. 以Id为目标的删除放在其他处: 也利用到了IndexId
+                if (propertyInfo.Name == nameof(IndexId))
                 {
-                    //1. 该处修复用IndexId去删除索引无效的问题
-                    if (propertyInfo.Name == nameof(LuceneIndexableBaseEntity.IndexId))
+                    var filed = new Field(propertyInfo.Name, propertyValue.ToString(), new FieldType
                     {
-                        var filed = new Field(propertyInfo.Name, propertyValue.ToString(), new FieldType()
-                        {
-                            IsStored = true,
-                            IsIndexed = true,
-                            IsTokenized = false
-                        });
-                        doc.Add(filed);
-                        continue;
-                    }
-
-                    //2. 以Id为目标的删除放在其他处: 也利用到了IndexId
-
-
+                        IsStored = true,
+                        IsIndexed = true,
+                        IsTokenized = false
+                    });
+                    doc.Add(filed);
+                    continue;
                 }
 
                 var attrs = propertyInfo.GetCustomAttributes<LuceneIndexAttribute>();
@@ -116,6 +111,10 @@ namespace Masuit.LuceneEFCore.SearchEngine
                             doc.Add(new DoubleField(name, num, attr.Store));
                             break;
 
+                        case Guid guid:
+                            doc.Add(new StringField(name, guid.ToString(), attr.Store));
+                            break;
+
                         default:
                             string value = attr.IsHtml ? propertyValue.ToString().RemoveHtmlTag() : propertyValue.ToString();
                             doc.Add(new TextField(name, value, attr.Store));

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

@@ -8,8 +8,8 @@
         <Description>基于EntityFrameworkCore和Lucene.NET实现的全文检索搜索引擎</Description>
         <Copyright>懒得勤快</Copyright>
         <PackageProjectUrl>https://github.com/ldqk/Masuit.LuceneEFCore.SearchEngine</PackageProjectUrl>
-        <PackageId>Masuit.LuceneEFCore.SearchEngine_guid</PackageId>
-        <Version>1.1.9</Version>
+        <PackageId>Masuit.LuceneEFCore.SearchEngine_int</PackageId>
+        <Version>1.2</Version>
         <Configurations>Debug;Release;String版本;Guid版本;Long版本</Configurations>
         <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
         <RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>