Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between LinqToLucene and Lucene.Net.Linq

  1. Are the LinqToLucene and the Lucene.Net.Linq projects different?
  2. What are the pros and cons of each of them?
  3. Since I found Lucene.Net.Linq to be updated more recently relative to LinqToLucene and it is available in nuget I want to use it in my simple project, but I came across lack of documentation and I can't find how can I use lucene advanced queries with this package like what are 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 this extension functions aren't available then what is the point of this project?

  4. If it is not the point how can i use advance queries in LINQ to Lucene.Net?
like image 462
alizx Avatar asked Aug 14 '14 04:08

alizx


1 Answers

LINQ to Lucene appears to be inactive. The last commit at time of writing was in October 2012 and the last discussion post asking if the project is active has gone unanswered since the same time frame.

LINQ to Lucene has some tight coupling to Entity Framework so it seems to me 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 have been actively maintaining. This project does not have any coupling to EF or other libraries. It only depends on Lucene.Net, Common.Logging for logging, and Remotion.Linq for helping with LINQ query parsing and translation. I originally evaluated the possibility of contributing to LINQ to Lucene, but found that the tight coupling to EF and some other assumptions made the library inappropriate for my needs.

LINQ to Lucene cons:

  1. Not available on NuGet
  2. Not actively maintained
  3. Very limited in what you can put into a where clause
  4. Coupled to EF whether you want it or not

Lucene.Net.Linq pros:

  1. Actively maintained
  2. Packages (and symbols!) published to NuGet
  3. Better comprehension of complex queries
  4. Fluent and Attribute APIs to map properties to fields and control analysis, storage and indexing

Lucene.Net.Linq cons:

  1. Documentation could be better
  2. Only a handful of contributions outside my own
  3. Unclear performance vs vanilla Lucene.Net (not much performance testing has been done)

The documentation, such that it is, consists of the project README and sample code in the unit test project.

Lucene.Net.Linq does not have extension methods for every query that Lucene.Net supports natively. However, it does provide an escape hatch where you can pass in your own Query:

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

And it supports searching any indexed field with fuzzy match:

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 meaning of == is controlled by how a given field is indexed. If the field is indexed as a keyword, exact matching takes effect. If the field is tokenized, stemmed, converted to lowercase, etc, then == would match any term in the field.

like image 86
Chris Eldredge Avatar answered Oct 29 '22 03:10

Chris Eldredge