The difference between LinqToLucene and Lucene.Net.Linq

  • Are there LinqToLucene and Lucene.Net.Linq projects?
  • What are the pros and cons of each?
  • Since I discovered that Lucene.Net.Linq will be updated quite recently with respect to LinqToLucene, and it is available on nuget, I want to use it in my simple project, but I ran into a lack of documentation and I can not find how I can use lucene extended queries with this package, like what is possible in LinqToLucene, for example:

    var query = from c in index.Customers where c.Like("amber") || c.CompanyName.Between("a", "d") where !c.CustomerId == "Jason" 

    If these extension features are not available, what is the point of this project?

  • If not, how can I use preliminary queries in LINQ for Lucene.Net?
+8
source share
2 answers

LINQ to Lucene seems to be inactive. The last fix at the time of writing was in October 2012, and the last discussion post asking if the project was active remained unanswered from the same time interval.

LINQ to Lucene is closely related to the Entity Framework, so it seems to me that the project is designed to index data coming from EF for free text search.

Lucene.Net.Linq is a completely separate project that I started in 2012 and actively supported. This project has no affiliation with EF or other libraries. It depends only on Lucene.Net, Common.Logging for logging, and Remotion.Linq to help analyze and translate LINQ queries. I initially appreciated the possibility of introducing LINQ into Lucene, but found that a tight connection with EF and some other assumptions made the library unsuitable for my needs.

LINQ to Lucene cons:

  • Not available on NuGet
  • Not actively supported
  • Very limited in what you can put in a where clause
  • In combination with EF, whether you want it or not

Lucene.Net.Linq pros:

  • Actively supported
  • Packages (and characters!) Published on NuGet
  • Better understanding of complex queries
  • Fluent and Attribute APIs for mapping properties to fields and controlling analysis, storage, and indexing

Lucene.Net.Linq minus:

  • Documentation could be better.
  • Only a few contributions beyond my own
  • Fuzzy performance against vanilla Lucene.Net (not many performance tests)

Documentation such as this consists of a README project and sample in a unit test project.

Lucene.Net.Linq does not have extension methods for each request that Lucene.Net supports natively. However, it provides an exit hatch in which you can pass your own Query :

 var result = customers .Where(new TermRangeQuery("CompanyName", "A", "C", includeLower: true, includeUpper: true)) .ToList(); 

And it supports searching in any fuzzy matching indexed field:

 var result = customers .Where(c => (c.AnyField() == "amber").Fuzzy(1.0f)) .ToList(); 

And it supports simple matching with == and != :

 var result = customers .Where(c => c.CustomerId != "Jason") .ToList(); 

Note that the == value is controlled by how the specified field is indexed. If the field is indexed as a keyword, then the exact match takes effect. If the field is indicated, initialized, converted to lowercase, etc., then == will match any member in the field.

+9
source share

With this code:

 var directory = FSDirectory.Open(AppDomain.CurrentDomain.BaseDirectory + "/index/recipes"); using(var provider = new LuceneDataProvider(directory, Lucene.Net.Util.Version.LUCENE_30)) { using(var session = provider.OpenSession < CatalogItemDocument > ()) {} } 

you can work with the file system, not the system memory.

-one
source share

All Articles