Foundatio.Parsers.SqlQueries
7.17.11
Prefix Reserved
dotnet add package Foundatio.Parsers.SqlQueries --version 7.17.11
NuGet\Install-Package Foundatio.Parsers.SqlQueries -Version 7.17.11
<PackageReference Include="Foundatio.Parsers.SqlQueries" Version="7.17.11" />
paket add Foundatio.Parsers.SqlQueries --version 7.17.11
#r "nuget: Foundatio.Parsers.SqlQueries, 7.17.11"
// Install Foundatio.Parsers.SqlQueries as a Cake Addin #addin nuget:?package=Foundatio.Parsers.SqlQueries&version=7.17.11 // Install Foundatio.Parsers.SqlQueries as a Cake Tool #tool nuget:?package=Foundatio.Parsers.SqlQueries&version=7.17.11
A lucene style query parser that is extensible and allows additional syntax features. Also includes an Elasticsearch query_string query replacement that greatly enhances its capabilities for dynamic queries.
Getting Started (Development)
This package can be installed via the NuGet package manager. If you need help, please contact us via in-app support or open an issue. We’re always here to help if you have any questions!
- You will need to have Visual Studio Code installed.
- Open the
Foundatio.Parsers.sln
Visual Studio solution file.
Using LuceneQueryParser
Below is a small sampling of the things you can accomplish with LuceneQueryParser, so check it out! We use this library extensively in Exceptionless!
In the sample below we will parse a query and output it's structure using the DebugQueryVisitor
and then generate the same exact query using the parse result.
using Foundatio.Parsers.LuceneQueries;
using Foundatio.Parsers.LuceneQueries.Visitors;
var parser = new LuceneQueryParser();
var result = parser.Parse("field:[1 TO 2]");
Debug.WriteLine(DebugQueryVisitor.Run(result));
Here is the parse result as shown from the DebugQueryVisitor
Group:
Left - Term:
TermMax: 2
TermMin: 1
MinInclusive: True
MaxInclusive: True
Field:
Name: field
Finally, lets translate the parse result back into the original query.
var generatedQuery = GenerateQueryVisitor.Run(result);
System.Diagnostics.Debug.Assert(query == generatedQuery);
Query Syntax
Aggregation Syntax
Features
- Lucene Query Syntax Parser
- Parsers fairly standardized syntax from Lucene and Elasticsearch.
- Visitors for extensibility
- Field Aliases (static and dynamic)
- Query Includes
- Define stored queries that can be included inside other queries as macros that will be expanded
- Validation
- Validate query syntax
- Restrict access to specific fields
- Restrict the number of operations allowed
- Restrict nesting depth
- Elasticsearch
- Elastic query string query replacement on steriods
- Dynamic search and filter expressions
- Dynamic aggregation expressions
- Supported bucket aggregations: terms, geo grid, date histogram, numeric histogram
- Bucket aggregations allow nesting other dynamic aggregations inside
- Supported metric aggregations: min, max, avg, sum, stats, extended stats, cardinality, missing, percentiles
- Supported bucket aggregations: terms, geo grid, date histogram, numeric histogram
- Dynamic sort expressions
- Dynamic expressions can be exposed to end users to allow for custom searches, filters, sorting and aggregations
- Enables allowing users to build custom views, charts and dashboards
- Enables powerful APIs that allow users to do things you never thought of
- Supports geo queries (proximity and radius)
- mygeo:75044~75mi
- Returns all documents that have a value in the mygeo field that is within a 75 mile radius of the 75044 zip code
- mygeo:75044~75mi
- Supports nested document mappings
- Automatically resolves non-analyzed keyword sub-fields for sorting and aggregations
- Aliases can be defined right on your NEST mappings
- Supports both root and inner field name aliases
Thanks to all the people who have contributed
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Exceptionless.DateTimeExtensions (>= 3.4.3)
- Foundatio.Parsers.LuceneQueries (>= 7.17.11)
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- System.Linq.Dynamic.Core (>= 1.4.5)
- System.Text.Json (>= 8.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.