Skip to content

FoundatioFx/Foundatio.Lucene

Repository files navigation

Build status NuGet Version feedz.io Discord

Foundatio.Lucene

A library for adding dynamic Lucene-style query capabilities to your .NET applications. Enable your users to write powerful search queries using familiar Lucene syntax, with support for Entity Framework and Elasticsearch.

This project is a modern replacement for Foundatio.Parsers.

✨ Why Choose Foundatio Lucene?

  • 🔍 Full Lucene Syntax - Terms, phrases, fields, ranges, boolean operators, wildcards, regex
  • Entity Framework Integration - Convert Lucene queries directly to LINQ expressions
  • 🔎 Elasticsearch Support - Generate Elasticsearch Query DSL using the official .NET 9.x client
  • 🧩 Visitor Pattern - Transform, validate, or analyze queries with composable visitors
  • 🗺️ Field Aliasing - Map user-friendly field names to your actual data model
  • Query Validation - Restrict allowed fields, operators, and patterns
  • 🔄 Round-Trip Capable - Parse queries to AST and convert back to query strings
  • 🛡️ Error Recovery - Resilient parser returns partial AST with detailed error information

🚀 Quick Example

using Foundatio.Lucene;
using Foundatio.Lucene.EntityFramework;

// Parse a Lucene query
var result = LuceneQuery.Parse("title:hello AND status:active");

// Or build LINQ expressions for Entity Framework
var parser = new EntityFrameworkQueryParser();
Expression<Func<Employee, bool>> filter = parser.BuildFilter<Employee>(
    "name:john AND salary:[50000 TO *]"
);

var employees = await context.Employees.Where(filter).ToListAsync();

📚 Learn More

👉 Complete Documentation

Key topics:

📦 CI Packages (Feedz)

Want the latest CI build before it hits NuGet? Add the Feedz source (read-only public) and install the pre-release version:

dotnet nuget add source https://f.feedz.io/foundatio/foundatio/nuget -n foundatio-feedz
dotnet add package Foundatio.Lucene --prerelease

Or add to your NuGet.config:

<configuration>
    <packageSources>
        <add key="foundatio-feedz" value="https://f.feedz.io/foundatio/foundatio/nuget" />
    </packageSources>
    <packageSourceMapping>
        <packageSource key="foundatio-feedz">
            <package pattern="Foundatio.*" />
        </packageSource>
    </packageSourceMapping>
</configuration>

CI builds are published with pre-release version tags (e.g. 1.0.0-preview.12345+sha.abcdef). Use them to try new features early—avoid in production unless you understand the changes.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. See our documentation for development guidelines.

🔗 Related Projects

📄 License

Apache 2.0

About

Add dynamic Lucene-style query capabilities to your .NET applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages