Click or drag to resize

SphinxSearchOptionsSetFilterTFilterable Method (String, TFilterable)

Sets a filter for the attribute with the given name.

Namespace:  SphinxConnector.NativeApi
Assembly:  SphinxConnector (in SphinxConnector.dll) Version: 5.3.0
Syntax
public void SetFilter<TFilterable>(
	string attributeName,
	params TFilterable[] value
)
where TFilterable : IFilterableType

Parameters

attributeName
Type: SystemString
The name of the attribute to filter on.
value
Type: TFilterable
The value for the filter.

Type Parameters

TFilterable
The type to set a filter for.
Exceptions
ExceptionCondition
ArgumentNullExceptionattributeName or value is null.
ArgumentExceptionattributeName is empty.
Examples
The following example shows how to filter films based on the actor_id attribute. The filter will match any films with actor_id equal to 35 OR 28.
SphinxClient sphinxClient = new SphinxClient();
sphinxClient.SearchOptions.SetFilter<SphinxInteger>("actor_id", 35, 28);

SphinxSearchResult searchResult = sphinxClient.Query("room", "sakila");

foreach (SphinxMatch sphinxMatch in searchResult.Matches)
{
    Console.WriteLine(sphinxMatch);
}
If you wanted to retrieve all films with actor_id equal to 35 AND 28, you would call the SetFilter method like this:
sphinxClient.SearchOptions.SetFilter<SphinxInteger>("actor_id", 35);
sphinxClient.SearchOptions.SetFilter<SphinxInteger>("actor_id", 28);
See Also