1. Stylelabs.M.Sdk.Models.Clients

Class QueryingClientBase

Base class for querying clients.

Inheritance

object

QueryingClientBase

Implements

IQueryingClient

Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsClients

Assembly: Stylelabs.M.Sdk.dll

Syntax

public abstract class QueryingClientBase : IQueryingClient

Constructors

QueryingClientBase(IMClient)

Initializes a new instance of the QueryingClientBase class.

Declaration

protected QueryingClientBase(IMClient client)

Parameters

TypeNameDescription
IMClientclientThe client.

Methods

CreateEntityIdIterator(Query)

Creates an IEntityIterator that iterates over all ids matched by the Query.

Declaration

public IIdIterator CreateEntityIdIterator(Query query)

Parameters

TypeNameDescription
QueryqueryThe query to iterate.

Returns

TypeDescription
IIdIteratorAn iterator.

CreateEntityIdScroller(Query, TimeSpan?)

Creates an IIdScroller that scrolls over all ids of entities that match the Query.

Declaration

public IIdScroller CreateEntityIdScroller(Query query, TimeSpan? scrollTime = null)

Parameters

TypeNameDescription
QueryqueryThe query to scroll.
TimeSpanscrollTimeThe time for the scroll to live. If it is not specified, ScrollTime will be used. The scroll time should not be too long, just enough to process each batch of results.

Returns

TypeDescription
IIdScrollerAn IIdScroller instance.

Remarks

Use scrolling wisely and try to limit the scrollTime for the scroll to live. Using scrolling inappropriately can cause performance issues. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html for more information.

CreateEntityIterator(Query, IEntityLoadConfiguration)

Creates an IEntityIterator that iterates over all results matched by the Query.

Declaration

public IEntityIterator CreateEntityIterator(Query query, IEntityLoadConfiguration loadConfiguration = null)

Parameters

TypeNameDescription
QueryqueryThe query to iterate.
IEntityLoadConfigurationloadConfigurationThe load configuration. If it is null, then Default will be used.

Returns

TypeDescription
IEntityIteratorAn iterator.

Remarks

For compatibility with the 3.0 SDK, the loading configuration is resolved as follows:

  1. The loadConfiguration will be used, if not null.
  2. The IQueryLoadConfiguration from the query will be used, if not null and if applicable.
  3. Otherwise, defaults to Default.

CreateEntityScroller(Query, TimeSpan?, IEntityLoadConfiguration)

Creates an IEntityScroller that scrolls over all entities that match the Query.

Declaration

public IEntityScroller CreateEntityScroller(Query query, TimeSpan? scrollTime = null, IEntityLoadConfiguration loadConfiguration = null)

Parameters

TypeNameDescription
QueryqueryThe query to scroll.
TimeSpanscrollTimeThe time for the scroll to live. If it is not specified, ScrollTime will be used. The scroll time should not be too long, just enough to process each batch of results.
IEntityLoadConfigurationloadConfigurationThe load configuration. If it is null, then Default will be used.

Returns

TypeDescription
IEntityScrollerAn IEntityScroller instance.

Remarks

Use scrolling wisely and try to limit the scrollTime for the scroll to live. Using scrolling inappropriately can cause performance issues. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html for more information.

GetEntityScrollEngine()

Gets the implementation specific scrolling engine for entity retrieval.

Declaration

protected abstract IScrollEngine<IEntityScrollResult> GetEntityScrollEngine()

Returns

GetIdScrollEngine()

Gets the implementation specific scrolling engine for id retrieval.

Declaration

protected abstract IScrollEngine<IIdScrollResult> GetIdScrollEngine()

Returns

QueryAsync(Query, IEntityLoadConfiguration)

Retrieves entities matching the query.

Declaration

public abstract Task<IEntityQueryResult> QueryAsync(Query query, IEntityLoadConfiguration loadConfiguration = null)

Parameters

TypeNameDescription
QueryqueryThe query to execute.
IEntityLoadConfigurationloadConfigurationThe load configuration. If it is null, then Default will be used.

Returns

TypeDescription
Task<>IEntityQueryResultAn IEntityQueryResult containing the results of the query.

Remarks

For compatibility with the 3.0 SDK, the loading configuration is resolved as follows:

  1. The loadConfiguration will be used, if not null.
  2. The IQueryLoadConfiguration from the query will be used, if not null and if applicable.
  3. Otherwise, defaults to Default.

QueryIdsAsync(Query)

Retrieves the ids of entities matching the query.

Declaration

public abstract Task<IIdQueryResult> QueryIdsAsync(Query query)

Parameters

TypeNameDescription
QueryqueryThe query to execute.

Returns

TypeDescription
Task<>IIdQueryResultAn IEntityQueryResult containing the results of the query.

ResolveLoadConfiguration(Query, IEntityLoadConfiguration)

This is used to get a valid entity load config from a query for compatibility with the 3.0 SDK.

Situation: in 3.0 we only had the query as parameter in the query client, and the load config was on the query. In 3.1 we have the query and optional load config from as parameter.

For compatibility, the query load config needs priority if the load config was not specified as parameter.

Declaration

protected static IQueryLoadConfiguration ResolveLoadConfiguration(Query query, IEntityLoadConfiguration loadConfiguration)

Parameters

TypeNameDescription
QueryqueryThe Query.
IEntityLoadConfigurationloadConfigurationThe IEntityLoadConfiguration.

Returns

SingleAsync(Query, IEntityLoadConfiguration)

Gets a single entity that matches the query.

Declaration

public Task<IEntity> SingleAsync(Query query, IEntityLoadConfiguration loadConfiguration = null)

Parameters

TypeNameDescription
QueryqueryThe query to execute.
IEntityLoadConfigurationloadConfigurationThe load configuration. If it is null, then Default will be used.

Returns

TypeDescription
Task<>IEntityThe entity that matches the query or null if there are no results.

Remarks

For compatibility with the 3.0 SDK, the loading configuration is resolved as follows:

  1. The loadConfiguration will be used, if not null.
  2. The IQueryLoadConfiguration from the query will be used, if not null and if applicable.
  3. Otherwise, defaults to Default.

SingleIdAsync(Query)

Gets a the id of the entity that matches the query.

Declaration

public Task<long?> SingleIdAsync(Query query)

Parameters

TypeNameDescription
QueryqueryThe query to execute.

Returns

TypeDescription
Task<>longThe id of the entity that matches the query or null if there are no results.

Implements

IQueryingClient

If you have suggestions for improving this article, let us know!