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?
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.
where
clauseThe 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With