Поделиться через


IContentList::Filter Method

Use this method to filter items in a ContentList object. Items that do not pass the filter have their scores set to zero (0).

HRESULT IContentList::Filter(
  VARIANT vColumn,
  VARIANT vFilterCriteria,
  FilterActionEnum FilterAction,
  BSTR Component
);
Sub Filter(
    vColumn As Variant,
    vFilterCriteria As Variant,
    FilterAction As FilterActionEnum,
    Component As String
)

Parameters

  • vColumn
    [C++]

    [in] A VARIANT that identifies the column upon which to filter. The column is identified by either a number representing a column position, starting at zero (0), or a string containing a column name.

    [Visual Basic]

    A Variant that identifies the column for which the index will be built. The column is identified by either a number representing a column position, starting at zero (0), or a string containing a column name.

  • vFilterCriteria
    [C++]

    [in] A VARIANT that contains the filter criterion. The criterion is usually a BSTR, an integer, or a SAFEARRAY of VARIANTS containing BSTRs or integers.

    [Visual Basic]

    A Variant that contains the filter criterion. The criterion is either a single String, an array of Strings, or an Integer.

  • FilterAction
    [C++]

    [in] An enumeration value. Valid values are FILTER_REQUIRE and FILTER_EXCLUDE. See the Remarks section for more information about the consequences of these two actions.

    [Visual Basic]

    An enumeration value. Valid values are FILTER_REQUIRE and FILTER_EXCLUDE. See the Remarks section for more information about the consequences of these two actions.

  • Component
    [C++]

    [in,optional] A BSTR that is intended to contain the name of the pipeline component doing the filtering. This parameter is optional and is used for score tracing. Trace messages will be generated for content items that are filtered out.

    [Visual Basic]

    A String that is intended to contain the name of the pipeline component doing the filtering. This parameter is optional and is used for score tracing. Trace messages will be generated for content items that are filtered out.

Return Value

[C++]

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic]

None.

Error Values

[C++]

This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic]

This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

An item in the ContentList object matches the criteria if the value for the specified column exactly matches a string or number passed in the vFilterCriteria parameter. If the vFilterCriteria parameter is an array of strings, matching any one of the strings in the array is considered a match. If the FilterAction parameter is set to FILTER_REQUIRE, non-matching items have their scores set to zero (0). If the FilterAction parameter is set to FILTER_EXCLUDE, matching items have their scores set to zero (0).

For the sake of uniformity, the pipeline components provided with Commerce Server pass their own Programmatic Identifier (ProgID) for the Component parameter.

Example

myContentList.Filter "Score", 3, 

See Also

Other Resources

ContentList Object