EasyLuceneNET 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyLuceneNET --version 1.4.0                
NuGet\Install-Package EasyLuceneNET -Version 1.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyLuceneNET" Version="1.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyLuceneNET --version 1.4.0                
#r "nuget: EasyLuceneNET, 1.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasyLuceneNET as a Cake Addin
#addin nuget:?package=EasyLuceneNET&version=1.4.0

// Install EasyLuceneNET as a Cake Tool
#tool nuget:?package=EasyLuceneNET&version=1.4.0                

基于https://github.com/SilentCC/JIEba-netcore 封装了一个lucene.net的全文检索工具

使用

安装nuget包

Install-Package EasyLuceneNET

创建模型

 public class Article
    {
        [Lucene(FieldStore = Field.Store.YES, IsUnique = true, type = LuceneFieldType.Int32)]
        public int Id { get; set; }
        [Lucene(FieldStore = Field.Store.YES, IsUnique = false, type = LuceneFieldType.Text)]
        public string Title { get; set; }


        [Lucene(FieldStore = Field.Store.YES, IsUnique = false, type = LuceneFieldType.Text)]
        public string Content { get; set; }
    }

依赖注入

var service = new ServiceCollection();
service.AddLogging();
service.AddEasyLuceneNet();
var serviceProvider = service.BuildServiceProvider();

var easy = serviceProvider.GetService<IEasyLuceneNet>();

创建索引



var list = new List<Article>();
for (int i = 0; i < 100; i++)
{
    list.Add(new Article()
    {
        Id = i,
        Title = i + "使用Xamarin开发移动应用示例——数独游戏(八)使用MVVM实现完成游戏列表页面",
        Content = @"前面我们已经完成了游戏的大部分功能,玩家可以玩预制的数独游戏,也可以自己添加新的游戏。现在我们实现展示已完成游戏列表页面,显示用户已经完成的游戏列表,从这个列表可以进入详细的复盘页面。

前面的页面我们采用的是传统的事件驱动模型,在XAML文件中定义页面,在后台的cs文件中编写事件响应代码。采用这种模型是因为很多页面需要动态生成控件,然后动态改变这些控件的属性,事件驱动模型在这种场景下比较好理解。现在我们采用MVVM方式编写完成游戏列表页面。

MVVM是将页面绑定到视图模型,所有的操作和事件响应通过视图模型完成。视图模型中没有页面控件的定义,因此和页面是解耦的,可以独立进行测试。在视图模型中我们只关心数据,而不关心展示数据的控件。

首先,我们定义一个视图模型的基类,下一步在改造其它页面时,会用到这个基类:"
    });
}
easy!.AddIndex(list);

检索

var result = easy!.Search<Article>(new SearchRequest()
{
    keyword = "事件模型",
    index = 1,
    size = 20,
    fields = new string[] { "Title", "Content" },
    OrderByField = "Id",
});
Console.WriteLine("一共:" + result.Total);
foreach (var item in result.list)
{
    Console.WriteLine($"id:{item.Id} title:{item.Title}");
}
Console.WriteLine($"分词:{string.Join(" ", result.cutKeys)}");
Console.WriteLine("完成");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 546 2/11/2022
1.4.0 458 2/11/2022
1.3.0 444 2/10/2022
1.2.0 443 2/10/2022
1.1.0 440 2/10/2022
1.0.0 438 2/9/2022