Enterspeed.Query.Sdk 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Enterspeed.Query.Sdk --version 1.1.0
                    
NuGet\Install-Package Enterspeed.Query.Sdk -Version 1.1.0
                    
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="Enterspeed.Query.Sdk" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Enterspeed.Query.Sdk" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Enterspeed.Query.Sdk" />
                    
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 Enterspeed.Query.Sdk --version 1.1.0
                    
#r "nuget: Enterspeed.Query.Sdk, 1.1.0"
                    
#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 Enterspeed.Query.Sdk@1.1.0
                    
#: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=Enterspeed.Query.Sdk&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Enterspeed.Query.Sdk&version=1.1.0
                    
Install as a Cake Tool

Enterspeed Query .NET SDK · GitHub license NuGet version PRs Welcome

Installation

With .NET CLI

dotnet add package Enterspeed.Query.Sdk --version <version>

With Package Manager

Install-Package Enterspeed.Query.Sdk -Version <version>

How to use

Register services

Service has to be added to the service collection. This can be one by using the following extension method.

using IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureServices((_, services) =>
        services.AddEnterspeedQueryService())
    .Build();

Examples of usage

Example of a common implementation where the query service is being utilized.

using System.Text.Json.Serialization;
using Enterspeed.Query.Sdk.Api.Extensions;
using Enterspeed.Query.Sdk.Api.Models;
using Enterspeed.Query.Sdk.Api.Services;
using Enterspeed.Query.Sdk.Domain.Models;
using Enterspeed.Query.Sdk.Domain.Models.FilterOperators;
using Enterspeed.Query.Sdk.Domain.Models.LogicalOperators;

namespace Query;

public class MyQueryService
{
    private readonly IEnterspeedQueryService _enterspeedQueryService;

    public MyQueryService(IEnterspeedQueryService enterspeedQueryService)
    {
        _enterspeedQueryService = enterspeedQueryService;
    }

    // Query an Enterspeed index 
    public async Task<QueryApiResponse> Query()
    {
        var query = new QueryObject
        {
            Sort = new List<Sort>
            {
                new Sort()
                {
                    Field = "_updatedAt",
                    Order = SortOrder.Desc
                }
            },
            Facets = new List<Facet>
            {
                new Facet()
                {
                    Field = "tags",
                    Name = "Tags",
                    Size = 3
                }
            },
            Filters = new AndOperator
            {
                And = new List<IOperator>
                {
                    new EqualsOperator<bool>
                    {
                        Field = "isActive",
                        Value = true
                    },
                    new OrOperator
                    {
                        Or = new List<IOperator>
                        {
                            new EqualsOperator<bool>
                            {
                                Field = "isGlobal",
                                Value = true
                            },
                            new InOperator<string>
                            {
                                Field = "category",
                                Value = new List<string> { "selected category 1", "selected category 2" }
                            }
                        }
                    }
                }
            },
            Aliases = new List<string> { "blogPostTile" },
            Pagination = new Pagination
            {
                Page = 0,
                PageSize = 10
            }
        };

        var response = await _enterspeedQueryService.Query("environment-******-****-****-****-**********", "blogIndex", query);

        return response;
    }

    // Query an Enterspeed index and get strongly typed result
    public async Task<List<BlogPost>> QueryTyped()
    {
        var typedResult = await _enterspeedQueryService.QueryTyped("environment-******-****-****-****-**********", "blogIndex", new QueryObject());

        List<BlogPost> blogPosts = typedResult.Response.Results.GetContent<BlogPost>();

        return blogPosts;
    }

    // Multiple queries against an Enterspeed index 
    public async Task<MultiQueryApiResponse> MultiQuery()
    {
        var multiQuery = new List<MultiQueryObject>{
            new()
            {
                Index = "blogIndex",
                Name = "blogPosts",
                Filters = new AndOperator
                {
                    And = new List<IOperator>
                    {
                        new EqualsOperator<string>
                        {
                            Field = "title",
                            Value = "My Blog Post",
                            CaseInsensitive = true
                        }
                    }
                },
                Pagination = new Pagination
                {
                    Page = 0,
                    PageSize = 10
                }
            },
            new()
            {
                Index = "blogIndex",
                Name = "allCategoryFacets",
                Facets = new List<Facet>
                {
                    new()
                    {
                        Field = "category",
                        Name = "Category"
                    }
                },
                Pagination = new Pagination
                {
                    Page = 0,
                    PageSize = 0
                }
            }
        };

        var response = await _enterspeedQueryService.Query("environment-******-****-****-****-**********", multiQuery);

        var blogPostsQueryResponse = response.Response.Single(x => x.Name == "blogPosts");
        var allFacetsQueryResponse = response.Response.Single(x => x.Name == "allFacets");

        return response;
    }

    // Multiple queries against an Enterspeed index and get strongly typed results
    public async Task<MultiQueryApiResponse<IContent>> MultiQueryTyped()
    {
        var multiQuery = new List<MultiQueryObject>{
            new()
            {
                Index = "blogIndex",
                Name = "blogPosts",
                Sort = new List<Sort>
                {
                    new()
                    {
                        Field = "_updatedAt",
                        Order = SortOrder.Desc
                    }
                },
                Pagination = new Pagination
                {
                    Page = 0,
                    PageSize = 10
                }
            },
            new()
            {
                Index = "productIndex",
                Name = "products",
                Sort = new List<Sort>
                {
                    new()
                    {
                        Field = "_updatedAt",
                        Order = SortOrder.Desc
                    }
                },
                Pagination = new Pagination
                {
                    Page = 0,
                    PageSize = 10
                }
            }
        };

        var response = await _enterspeedQueryService.QueryTyped("environment-******-****-****-****-**********", multiQuery);

        List<BlogPost> blogPosts = response.Response.Single(x => x.Name == "blogPosts").Results.GetContent<BlogPost>();
        List<Product> products = response.Response.Single(x => x.Name == "allFacets").Results.GetContent<Product>();

        return response;
    }

    public class BlogPost
    {
        [JsonPropertyName("date")]
        public DateTime PublishedDate { get; set; }
        public string Title { get; set; }
        public string AuthorName { get; set; }
        public string[] Tags { get; set; }
    }

    public class Product
    {
        public string Url { get; set; }
        public string ProductName { get; set; }
        public double Price { get; set; }
        public string Sku { get; set; }
        public string Category { get; set; }
    }
}

Contributing

Pull requests are very welcome.
Please fork this repository and make a PR when you are ready.

Otherwise you are welcome to open an Issue in our issue tracker.

License

Enterspeed .NET SDK is MIT licensed

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 was computed.  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

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
2.0.0 489 3/5/2026
1.1.0 229 1/6/2026
1.0.0 566 11/5/2025
1.0.0-alpha.1.0.0.0 178 11/4/2025