懒得勤快 преди 6 години
родител
ревизия
fd58aa6fd9

+ 2 - 2
Masuit.LuceneEFCore.SearchEngine.Test/Models/City.cs

@@ -2,12 +2,12 @@
 {
     public class City : LuceneIndexableBaseEntity
     {
-        [LuceneIndexable]
+        [LuceneIndex]
         public string Name { get; set; }
 
         public string Code { get; set; }
 
-        [LuceneIndexable]
+        [LuceneIndex]
         public string Country { get; set; }
 
     }

+ 4 - 4
Masuit.LuceneEFCore.SearchEngine.Test/Models/User.cs

@@ -2,16 +2,16 @@
 {
     public class User : LuceneIndexableBaseEntity
     {
-        [LuceneIndexable]
+        [LuceneIndex]
         public string FirstName { get; set; }
 
-        [LuceneIndexable]
+        [LuceneIndex]
         public string Surname { get; set; }
 
-        [LuceneIndexable]
+        [LuceneIndex]
         public string Email { get; set; }
 
-        [LuceneIndexable]
+        [LuceneIndex]
         public string JobTitle { get; set; }
 
     }

+ 2 - 2
Masuit.LuceneEFCore.SearchEngine/LuceneIndexableAttribute.cs → Masuit.LuceneEFCore.SearchEngine/LuceneIndexAttribute.cs

@@ -7,9 +7,9 @@ namespace Masuit.LuceneEFCore.SearchEngine
     /// 标记该字段可被索引
     /// </summary>
     [AttributeUsage(AttributeTargets.Property)]
-    public class LuceneIndexableAttribute : Attribute
+    public class LuceneIndexAttribute : Attribute
     {
-        public LuceneIndexableAttribute()
+        public LuceneIndexAttribute()
         {
             Index = Field.Index.ANALYZED;
             Store = Field.Store.YES;

+ 4 - 4
Masuit.LuceneEFCore.SearchEngine/LuceneIndexableBaseEntity.cs

@@ -16,13 +16,13 @@ namespace Masuit.LuceneEFCore.SearchEngine
         /// <summary>
         /// 主键id
         /// </summary>
-        [LuceneIndexable(Name = "Id", Store = Field.Store.YES, Index = Field.Index.NOT_ANALYZED), Key]
+        [LuceneIndex(Name = "Id", Store = Field.Store.YES, Index = Field.Index.NOT_ANALYZED), Key]
         public int Id { get; set; }
 
         /// <summary>
         /// 索引唯一id
         /// </summary>
-        [LuceneIndexable(Name = "IndexId", Store = Field.Store.YES, Index = Field.Index.NOT_ANALYZED)]
+        [LuceneIndex(Name = "IndexId", Store = Field.Store.YES, Index = Field.Index.NOT_ANALYZED)]
         [NotMapped]
         public string IndexId
         {
@@ -46,8 +46,8 @@ namespace Masuit.LuceneEFCore.SearchEngine
                 object propertyValue = propertyInfo.GetValue(this);
                 if (propertyValue != null)
                 {
-                    IEnumerable<LuceneIndexableAttribute> attrs = propertyInfo.GetCustomAttributes<LuceneIndexableAttribute>();
-                    foreach (LuceneIndexableAttribute attr in attrs)
+                    IEnumerable<LuceneIndexAttribute> attrs = propertyInfo.GetCustomAttributes<LuceneIndexAttribute>();
+                    foreach (LuceneIndexAttribute attr in attrs)
                     {
                         string name = !string.IsNullOrEmpty(attr.Name) ? attr.Name : propertyInfo.Name;
                         string value = attr.IsHtml ? StringHelpers.RemoveUnwantedTags(propertyValue.ToString()) : propertyValue.ToString();

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

@@ -126,7 +126,7 @@ namespace Masuit.LuceneEFCore.SearchEngine
             var obj = t.Assembly.CreateInstance(t.FullName, true) as ILuceneIndexable;
             foreach (var p in t.GetProperties())
             {
-                if (p.GetCustomAttributes<LuceneIndexableAttribute>().Any())
+                if (p.GetCustomAttributes<LuceneIndexAttribute>().Any())
                 {
                     p.SetValue(obj, doc.Get(p.Name, p.PropertyType));
                 }

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

@@ -168,7 +168,7 @@ namespace Masuit.LuceneEFCore.SearchEngine
         /// <param name="size">页大小</param>
         /// <param name="page">第几页</param>
         /// <param name="t">需要被全文检索的类型</param>
-        public SearchOptions(string keywords, int page, int size, Type t) : this(keywords, string.Join(",", t.GetProperties().Where(p => p.GetCustomAttributes<LuceneIndexableAttribute>().Any()).Select(p => p.Name)), int.MaxValue, null, null, null, (page - 1) * size, size)
+        public SearchOptions(string keywords, int page, int size, Type t) : this(keywords, string.Join(",", t.GetProperties().Where(p => p.GetCustomAttributes<LuceneIndexAttribute>().Any()).Select(p => p.Name)), int.MaxValue, null, null, null, (page - 1) * size, size)
         {
             if (page < 1)
             {

+ 6 - 6
WebSearchDemo/Database/Post.cs

@@ -19,19 +19,19 @@ namespace WebSearchDemo.Database
         /// <summary>
         /// 标题
         /// </summary>
-        [Required(ErrorMessage = "文章标题不能为空!"), LuceneIndexable]
+        [Required(ErrorMessage = "文章标题不能为空!"), LuceneIndex]
         public string Title { get; set; }
 
         /// <summary>
         /// 作者
         /// </summary>
-        [Required, MaxLength(24, ErrorMessage = "作者名最长支持24个字符!"), LuceneIndexable]
+        [Required, MaxLength(24, ErrorMessage = "作者名最长支持24个字符!"), LuceneIndex]
         public string Author { get; set; }
 
         /// <summary>
         /// 内容
         /// </summary>
-        [Required(ErrorMessage = "文章内容不能为空!"), LuceneIndexable(IsHtml = true)]
+        [Required(ErrorMessage = "文章内容不能为空!"), LuceneIndex(IsHtml = true)]
         public string Content { get; set; }
 
         /// <summary>
@@ -42,19 +42,19 @@ namespace WebSearchDemo.Database
         /// <summary>
         /// 作者邮箱
         /// </summary>
-        [Required(ErrorMessage = "作者邮箱不能为空!"), LuceneIndexable]
+        [Required(ErrorMessage = "作者邮箱不能为空!"), LuceneIndex]
         public string Email { get; set; }
 
         /// <summary>
         /// 标签
         /// </summary>
-        [StringLength(256, ErrorMessage = "标签最大允许255个字符"), LuceneIndexable]
+        [StringLength(256, ErrorMessage = "标签最大允许255个字符"), LuceneIndex]
         public string Label { get; set; }
 
         /// <summary>
         /// 文章关键词
         /// </summary>
-        [StringLength(256, ErrorMessage = "文章关键词最大允许255个字符"), LuceneIndexable]
+        [StringLength(256, ErrorMessage = "文章关键词最大允许255个字符"), LuceneIndex]
         public string Keyword { get; set; }
 
     }