Browse Source

分词改进

懒得勤快 3 years ago
parent
commit
8aed1fcaa9

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

@@ -76,7 +76,7 @@ namespace Masuit.LuceneEFCore.SearchEngine
             list.RemoveAll(s => s.Length < 2);
             list.AddRange(KeywordsManager.SynonymWords.Where(t => list.Contains(t.key) || list.Contains(t.value)).SelectMany(t => new[] { t.key, t.value }));
             var pinyins = list.SelectMany(s => KeywordsManager.Pinyins.ToLookup(t => t.value)[PinyinHelper.GetPinyin(Regex.Replace(s, @"\p{P}|\p{S}", ""))].Select(t => t.key));
-            list = list.Union(pinyins).Distinct().OrderByDescending(s => s.Length).Take(10).ToList();
+            list = list.Union(pinyins).Distinct().OrderByDescending(s => s.Length).Take(10).Select(s => s.Trim('[', ']', '{', '}', '(', ')')).ToList();
             _memoryCache.Set(keyword, list, TimeSpan.FromHours(1));
             return list;
         }

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

@@ -89,7 +89,7 @@ namespace Masuit.LuceneEFCore.SearchEngine
         /// <param name="orderBy">排序字段</param>
         /// <param name="skip">跳过多少条</param>
         /// <param name="take">取多少条</param>
-        public SearchOptions(string keywords, string fields, int maximumNumberOfHits = 10000, Dictionary<string, float> boosts = null, Type type = null, string orderBy = null, int? skip = null, int? take = null)
+        public SearchOptions(string keywords, string fields, int maximumNumberOfHits = 1000, Dictionary<string, float> boosts = null, Type type = null, string orderBy = null, int? skip = null, int? take = null)
         {
             if (string.IsNullOrWhiteSpace(keywords))
             {
@@ -170,4 +170,4 @@ namespace Masuit.LuceneEFCore.SearchEngine
             _boosts[field] = boost;
         }
     }
-}
+}