Foundatio.Parsers.ElasticQueries 7.17.18

Prefix Reserved
dotnet add package Foundatio.Parsers.ElasticQueries --version 7.17.18
                    
NuGet\Install-Package Foundatio.Parsers.ElasticQueries -Version 7.17.18
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Foundatio.Parsers.ElasticQueries" Version="7.17.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Foundatio.Parsers.ElasticQueries" Version="7.17.18" />
                    
Directory.Packages.props
<PackageReference Include="Foundatio.Parsers.ElasticQueries" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Foundatio.Parsers.ElasticQueries --version 7.17.18
                    
#r "nuget: Foundatio.Parsers.ElasticQueries, 7.17.18"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Foundatio.Parsers.ElasticQueries@7.17.18
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Foundatio.Parsers.ElasticQueries&version=7.17.18
                    
Install as a Cake Addin
#tool nuget:?package=Foundatio.Parsers.ElasticQueries&version=7.17.18
                    
Install as a Cake Tool

FoundatioFoundatio

Build status NuGet Version feedz.io Discord

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!

  1. You will need to have Visual Studio Code installed.
  2. Open the Foundatio.Parsers.slnx 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
  • 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
    • 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
    • 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

contributors

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Foundatio.Parsers.ElasticQueries:

Package Downloads
Foundatio.Repositories.Elasticsearch

Generic Repository implementations for Elasticsearch.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.17.18 736 8/20/2025
7.17.17 560 5/15/2025
7.17.16 4,356 5/12/2025
7.17.15 502 5/9/2025
7.17.14 1,199 1/31/2025
7.17.13 5,097 1/13/2025
7.17.12 712 11/26/2024
7.17.11 809 9/27/2024
7.17.10 6,367 9/4/2024
7.17.9 393 8/31/2024
7.17.8 138 8/31/2024
7.17.7 13,574 3/27/2024
7.17.6 5,040 1/5/2024
7.17.4 10,714 6/23/2023
7.17.3 26,009 1/1/2023
7.17.2 26,101 5/18/2022
7.17.1 4,376 3/10/2022
7.17.0 1,394 3/7/2022
7.16.2 1,938 1/21/2022
7.16.1 1,605 1/21/2022
7.16.0 1,567 1/20/2022
7.15.1 1,778 10/15/2021
7.15.0 1,939 10/11/2021
7.13.0 17,486 7/8/2021
7.12.0 3,751 4/13/2021
7.11.0 597 2/18/2021
7.10.3 23,053 2/1/2021
7.10.2 4,885 1/15/2021
7.10.1 634 1/15/2021
7.10.0 5,293 11/17/2020
7.9.0 4,680 9/16/2020
7.9.0-beta5 1,029 9/15/2020
7.9.0-beta4 515 9/15/2020
7.9.0-beta3 1,273 8/28/2020
7.9.0-beta2 939 8/27/2020
7.9.0-beta1 998 8/25/2020
7.8.0-beta9 451 8/3/2020
7.8.0-beta8 1,044 7/29/2020
7.8.0-beta7 1,233 7/9/2020
7.8.0-beta12 996 8/10/2020
7.8.0-beta11 1,076 8/6/2020
7.8.0-beta10 636 8/5/2020
7.7.0-beta6 482 7/2/2020
7.7.0-beta5 1,235 6/20/2020
7.7.0-beta4 1,031 6/14/2020
7.7.0-beta3 1,180 6/6/2020
7.7.0-beta2 1,163 5/26/2020
7.6.2 21,785 3/25/2020
7.6.1 735 3/25/2020
7.6.0 3,354 2/27/2020
7.5.4 2,784 2/13/2020
7.5.3 1,646 2/10/2020
7.5.2 2,438 1/28/2020
7.5.1 2,428 1/17/2020
7.5.0 1,409 1/16/2020
7.5.0-rc1 586 1/14/2020
7.0.497 12,686 6/27/2019
5.6.521 4,001 9/19/2019
5.6.517 784 9/19/2019
5.6.508 2,944 8/30/2019
5.6.477 8,983 4/16/2019
5.6.445 2,280 3/15/2019
5.6.443 1,568 3/14/2019
5.6.441 1,543 3/14/2019
5.6.438 2,632 2/22/2019
5.6.436 837 2/22/2019
5.6.429 1,278 1/30/2019
5.6.398 8,364 11/9/2018
5.6.396 1,633 11/9/2018
5.6.389 5,800 9/7/2018
5.6.386 4,180 5/9/2018
5.6.365 3,487 11/30/2017
5.0.353 5,938 9/14/2017
5.0.350 1,362 9/14/2017
5.0.348 3,057 8/17/2017
5.0.339 1,435 7/24/2017
5.0.336 2,188 6/23/2017
5.0.323 1,500 5/5/2017
5.0.302-pre 1,084 3/17/2017
5.0.301-pre 1,089 3/16/2017
5.0.300-pre 1,112 3/16/2017
5.0.299-pre 1,076 3/16/2017
5.0.295-pre 1,081 3/16/2017
5.0.293-pre 1,293 3/11/2017
5.0.292-pre 1,160 3/11/2017
5.0.274-pre 2,240 3/5/2017
5.0.273-pre 2,231 2/28/2017
5.0.271-pre 1,680 2/28/2017
5.0.270-pre 1,091 2/28/2017
5.0.268-pre 1,181 2/20/2017
5.0.266-pre 6,142 2/16/2017
5.0.263-pre 1,698 2/15/2017
5.0.261-pre 1,630 2/15/2017
5.0.260-pre 1,665 2/14/2017
5.0.259-pre 1,684 2/14/2017
5.0.258-pre 1,096 2/8/2017
5.0.255-pre 1,096 2/7/2017
5.0.254-pre 2,258 2/6/2017
5.0.253-pre 1,541 2/6/2017
5.0.252-pre 1,541 2/4/2017
5.0.251-pre 1,566 2/3/2017
5.0.250-pre 1,106 2/3/2017
5.0.248-pre 1,053 2/2/2017
5.0.246-pre 2,522 1/30/2017
5.0.245-pre 1,105 1/29/2017
5.0.244-pre 1,093 1/28/2017
5.0.243-pre 1,099 1/27/2017
5.0.242-pre 1,107 1/27/2017
5.0.241-pre 1,063 1/24/2017
5.0.239-pre 1,088 1/19/2017
5.0.238-pre 1,069 1/19/2017
5.0.237-pre 1,071 1/19/2017
5.0.235-pre 1,068 1/19/2017
5.0.234-pre 1,086 1/17/2017
5.0.233-pre 4,459 1/12/2017
5.0.232-pre 1,069 1/9/2017
5.0.230-pre 1,111 1/9/2017
5.0.229-pre 1,094 1/6/2017
5.0.226-pre 1,124 1/5/2017
5.0.224-pre 1,095 1/5/2017
5.0.223-pre 2,820 12/29/2016
5.0.222-pre 1,684 12/28/2016
5.0.220-pre 1,078 12/22/2016
5.0.219-pre 2,897 12/16/2016
5.0.216-pre 1,096 12/15/2016
5.0.214-pre 1,668 12/13/2016
5.0.213-pre 2,501 12/13/2016
5.0.212-pre 1,142 12/13/2016
5.0.211-pre 2,494 12/10/2016
5.0.209-pre 1,172 12/9/2016
5.0.205-pre 1,611 12/6/2016
5.0.203-pre 1,618 12/6/2016
5.0.202-pre 1,119 12/6/2016
5.0.199-pre 1,106 12/5/2016
5.0.198-pre 1,093 12/5/2016
5.0.197-pre 1,131 12/2/2016
5.0.196-pre 1,129 11/30/2016
5.0.193-pre 1,627 11/29/2016
5.0.190-pre 1,140 11/29/2016
5.0.189-pre 2,118 11/29/2016
5.0.186-pre 1,679 11/29/2016
5.0.185-pre 1,145 11/29/2016
5.0.183-pre 1,146 11/29/2016
5.0.182-pre 1,131 11/29/2016
5.0.181-pre 1,665 11/28/2016
5.0.180-pre 1,108 11/28/2016
5.0.177-pre 1,125 11/28/2016
5.0.175-pre 1,078 11/28/2016
5.0.174-pre 1,160 11/28/2016
5.0.173-pre 1,116 11/28/2016
5.0.171-pre 1,067 11/26/2016
5.0.170-pre 1,592 11/25/2016
5.0.169-pre 1,638 11/23/2016
5.0.167-pre 1,697 11/18/2016
5.0.166-pre 1,135 11/18/2016
5.0.159-pre 1,093 11/17/2016
2.0.153-pre 1,353 11/16/2016
2.0.150-pre 1,610 11/15/2016
2.0.149-pre 1,107 11/15/2016
2.0.148-pre 1,095 11/15/2016
2.0.140-pre 1,104 11/9/2016
2.0.137-pre 1,070 11/9/2016
2.0.135-pre 2,539 10/26/2016
2.0.105-pre 1,999 10/5/2016
2.0.104-pre 1,069 10/5/2016
2.0.103-pre 1,090 10/5/2016
2.0.101-pre 2,432 10/3/2016
2.0.100-pre 1,067 10/3/2016
2.0.99-pre 1,088 9/30/2016
2.0.98-pre 1,049 9/30/2016
2.0.95-pre 1,085 9/28/2016
2.0.94-pre 1,141 9/27/2016
1.0.318 1,284 5/4/2017
1.0.305 4,239 3/17/2017
1.0.269 4,529 2/20/2017
1.0.267 4,036 2/16/2017
1.0.264 1,311 2/16/2017
1.0.231 4,467 1/9/2017
1.0.228 2,552 1/6/2017
1.0.227 1,321 1/6/2017
1.0.210 4,108 12/9/2016
1.0.207 1,357 12/8/2016
1.0.204 1,953 12/6/2016
1.0.195 2,057 11/30/2016
1.0.192 1,387 11/29/2016
1.0.187 2,091 11/29/2016
1.0.184 1,380 11/29/2016
1.0.176 2,059 11/28/2016
1.0.168 2,624 11/18/2016
1.0.165 1,366 11/18/2016
1.0.164 1,399 11/18/2016
1.0.147 3,577 11/15/2016
1.0.143 1,318 11/10/2016
1.0.142 1,305 11/10/2016
1.0.141 1,317 11/9/2016
1.0.138 1,292 11/9/2016
1.0.136 1,419 11/9/2016
1.0.131 2,021 10/21/2016
1.0.130 1,327 10/21/2016
1.0.129 2,574 10/21/2016
1.0.128 1,978 10/21/2016
1.0.127 1,326 10/21/2016
1.0.126 1,319 10/21/2016
1.0.125 1,934 10/21/2016
1.0.124 1,977 10/20/2016
1.0.123 1,339 10/19/2016
1.0.122 1,318 10/19/2016
1.0.120 1,295 10/19/2016
1.0.119 2,035 10/18/2016
1.0.115 1,346 10/10/2016
1.0.114 1,298 10/10/2016
1.0.108 2,757 10/7/2016
1.0.102 2,081 10/3/2016
1.0.97 1,952 9/30/2016
1.0.96 1,332 9/30/2016
1.0.91 2,125 9/23/2016
1.0.87 5,354 9/20/2016
1.0.86 3,092 9/16/2016
1.0.85 1,321 9/16/2016
1.0.84 1,852 9/15/2016
1.0.82 4,165 9/13/2016
1.0.81 1,411 9/13/2016
1.0.80 1,907 9/13/2016
1.0.78 1,339 9/13/2016