Skip to content

Expressive API for Solr, Lucene and Azure search using .Net

Notifications You must be signed in to change notification settings

Code-Miners/Lucinq

Repository files navigation

Lucinq - A Fluent / Expressive API for SOLR, Azure Search and Lucene.NET

This project gives fluent style API to SOLR, Azure Search and Lucene. The primary purpose of which is to make the syntax a little less verbose whilst retaining the inherent power and speed of those tools.

Wiki

More complete documentation can be found in the wiki which can be found here: https://github.com/Code-Miners/Lucinq/wiki

Features

  • A fluent style api for working with queries for most query types and groupings.
  • Paging
  • Sorting
  • Query manipulation - remove terms and re-run for example.
  • Collecting

Get it with NuGet

You can find the Nuget Package here: http://nuget.org/packages/Lucinq/

PM> Install-Package Lucinq

Example Syntax

Further examples can be found in the integration tests, however here is a quick overview of how the syntax looks

LuceneSearch search = new LuceneSearch(indexPath));

IQueryBuilder query = new QueryBuilder();

query.Term("field", "value");
query.Or
	(
		x => x.Term("_name", "work"),
		x => x.Term("_name", "text")
	);

LuceneSearchResult result = search.Execute(query.Build(), 20);	
foreach (Document document in result.GetTopDocuments())
{
	Console.WriteLine(document.GetValues("field")[0]);
}

OR

LuceneSearch search = new LuceneSearch(indexPath));

IQueryBuilder query = new IQueryBuilder();

query.Setup(
	x => x.Term("field", "value"),
	x => x.Or
			(
				y => y.Term("_name", "work"),
				y => y.Term("_name", "text")
			)
);

LuceneSearchResult results = search.Execute(query.Build(), 20);	
foreach (Document document in result.GetTopDocuments())
{
	Console.WriteLine(document.GetValues("field")[0]);
}

Further Projects

The intention at present is to allow the use of raw lucene with a view to writing overlays for Sitecore and potentially umbraco.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

About

Expressive API for Solr, Lucene and Azure search using .Net

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages