Search client

The Search client in the Web SDK enables developers to perform powerful and flexible search operations on entities. It supports full-text search, filtering, sorting, pagination, and localization.

The following methods are available.

SearchAsync

Performs a search for entities using a SearchRequest object that supports a wide range of filtering, sorting, and configuration options.

The parameters you can use with the SearchAsync method are detailed in the following table.

Property

Type

Description

Query

string

The search query string.

LogicalGroupingTemplate

string

Template for logical grouping.

SearchDefaults

string

Default search configuration.

ConfigurationCategory

string

Configuration category.

ComponentId

long

Component ID.

Culture

CultureInfo

Culture info (defaults to InvariantCulture).

Sorting

SortingRequestResource

Sorting expression.

CustomSorting

IDictionary<string, int>

Custom sorting.

Skip

int

Records to skip (pagination).

Take

int

Records to take (pagination, default is 25).

Filters

List<FieldFilterRequestResource>

Filters to apply.

FullTextFilters

List<string>

Full-text filters.

Fields

List<string>

Fields to include in results.

SavedSelection

long

Saved selection ID.

View

string

View type for results.

CalendarStartDate

DateTime

Calendar filter start date.

CalendarStopDate

DateTime

Calendar filter stop date.

SelectionPool

SelectionPoolFilterResource

Selection pool filter.

Aggregations

List<AggregationRequestResource>

Aggregation requests.

NestedRelations

IEnumerable<NestedRelationInfo>

Nested relations to include.

Group

SearchGroupRequestResource

Grouping request.

IsInitialRequest

bool

Indicates if this is the initial request.

TakeUserSettings

bool

Use user settings.

L10N

bool

Use localization.

VisualSearch

VisualSearchRequestResource

Visual search request.

ExtensionData

IDictionary<string, JToken>

Additional extension data.

The following code provides a full-text search example.

RequestResponse
var searchRequest = new SearchRequest
{
  ComponentId = 840,
  Culture = new CultureInfo("en-US"),
  Sorting = new SortingRequestResource
  {
    FieldName = "createdon",
    Ascending = false
  },
  Skip = 0,
  Take = 10,
  FullTextFilters = new List<string> { "Keyword" },
  Fields = new List<string> { "Title", "Description" }
};
var result = await MClient.Search.SearchAsync(searchRequest);

GetAllFacetValuesAsync

Retrieves all available values for a specified facet field using an AllFacetsRequest.

The parameters you can use with the GetAllFacetValuesAsync method are detailed in the following table.

                                                                                                                                                                                                 

Property

Type

Description

FacetFieldName

string

Name of the facet field.

Query

string

Optional query for facet values.

SearchConfigurationName

string

Name of the search configuration.

Culture

CultureInfo

Culture for facet values.

ComponentId

long

Component ID.

Filters

IList<FieldFilterRequestResource>

Filters to apply.

TakeUserSettings

bool

Use user settings.

L10N

bool

Use localization.

Skip

int

Records to skip (pagination).

Take

int

Records to take (pagination).

The following code provides an example of how to get facet values.

RequestResponse
var allFacetsRequest = new AllFacetsRequest
{
  FacetFieldName = $"taxonomy_items.{tagId}.children",
  Query = "",
  SearchConfigurationName = "DefaultSearchConfig",
  Culture = new CultureInfo("en-US"),
  ComponentId = 840,
  Filters = new List<FieldFilterRequestResource>(),
  TakeUserSettings = false,
  L10N = false,
  Skip = 0,
  Take = 10
};
var result = await MClient.Search.GetAllFacetValuesAsync(allFacetsRequest);

Exceptions

  • ArgumentNullException – if the request is null.

  • ArgumentOutOfRangeException – if Take or Skip is negative.

  • ArgumentException – if any filter or culture is invalid.

Do you have some feedback for us?

If you have suggestions for improving this article,