Klororf.AzSearchLinq
0.5.0-prerelease
See the version list below for details.
dotnet add package Klororf.AzSearchLinq --version 0.5.0-prerelease
NuGet\Install-Package Klororf.AzSearchLinq -Version 0.5.0-prerelease
<PackageReference Include="Klororf.AzSearchLinq" Version="0.5.0-prerelease" />
paket add Klororf.AzSearchLinq --version 0.5.0-prerelease
#r "nuget: Klororf.AzSearchLinq, 0.5.0-prerelease"
// Install Klororf.AzSearchLinq as a Cake Addin #addin nuget:?package=Klororf.AzSearchLinq&version=0.5.0-prerelease&prerelease // Install Klororf.AzSearchLinq as a Cake Tool #tool nuget:?package=Klororf.AzSearchLinq&version=0.5.0-prerelease&prerelease
AzSearchLinq
AzSearchLinq is a .Net package for simplify the queries to Azure Cognitive Search
Options avaibles in 0.5.0
Fluent Mode
You can create odata queries using a fluent mode, fast and more legible
var test = _searchClient.Fluent<Product>().
Parentheses(fluent =>
fluent.Equal(x => x.Description, "A")
.Equal(x => x.Price, 2)
.Parentheses(x => x.Equal(x => x.Size, "M"))
);
var test = _searchClient.Fluent<Product>()
.Equal(x => x.Description, "A")
.Greater(x => x.Price, 2);
all the operator are concatenated with "and" by default, if you want to change this indicate the LogicalOperator.Or parameter
_searchClient.Fluent<Product>()
.Equal(x => x.Size, "2")
.LessOrEqual(x => x.Price, 2, LogicalOperator.Or);
aditionally the conditional parameter helps you to ignore any query part based on a value
var x = 1 == 2;
_searchClient.Fluent<Product>()
.Equal(x => x.Size, "2")
.LessOrEqual(x => x.Price, 2, LogicalOperator.Or, x);
// this code produces: Size eq '2'
Where
- Filter with conditional operators (==,!=...)
- Filter with string operatos (StartsWith,EndsWith,Contains)
- use search.in method
- filter with lambdas for complex types
Select
- Get the results and transform to other types
Order
- Order By multiple collumns
Usage
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
var res = srchclient.Where<Product>(x =>x.ProductName != "Mr").Select(x=>x.Product);
Also you can concatenate multiple where
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
var res = srchclient.Where<Product>(x =>x.ProductName != "Mr")
.And(x=>x.Price == 20)
.Search();
/// produces ProductName ne 'Mr' and Price eq 20
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
var res = srchclient.Where<Product>(x =>x.ProductName != "Mr")
.Or(x=>x.Price == 20)
.Search();
/// produces ProductName ne 'Mr' or Price eq 20
Use logical operators
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
var res = srchclient.Where<Product>(x =>x.ProductName != "Mr" && x.Price >10)
.And(x=>x.Price == 20)
.Search();
Use string methods for search
/// is highly recomended set a custom analyzer for search
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
var res = srchclient.Where<Product>(x =>x.Description.StartsWith("Blu"))
.Search();
/// Produces search.ismatch('Blu*','Description')
Filter by the properties values
SearchClient srchclient = new SearchClient(serviceEndpoint, indexName, credential);
var res = srchclient.SubWhere<Product,Color>(x =>x.Colors,x=>x.Hex="anything")
.Search();
/// Produces Colors/any(x: x/Hex eq 'anything')
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
- Azure.Search.Documents (>= 11.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.7.0 | 76 | 5/21/2024 |
0.6.1 | 84 | 5/20/2024 |
0.6.0 | 82 | 5/10/2024 |
0.5.0-prerelease | 70 | 5/10/2024 |
0.4.0-alpha | 84 | 5/7/2024 |
0.3.0-alpha | 80 | 4/30/2024 |
0.2.1-alpha | 80 | 4/25/2024 |
0.2.0.3-alpha | 84 | 4/16/2024 |
0.2.0.2-alpha | 88 | 4/14/2024 |
0.2.0.1-alpha | 76 | 4/12/2024 |
0.1.1-alpha | 70 | 3/29/2024 |
0.1.0-alpha | 73 | 3/27/2024 |