Skip to content

/AWS1/IF_MPI=>SEARCHFACETS()

About SearchFacets

Returns available facet values for filtering listings, such as categories, pricing models, fulfillment option types, publishers, and customer ratings. Each facet value includes a count of matching listings.

Method Signature

METHODS /AWS1/IF_MPI~SEARCHFACETS
  IMPORTING
    !IV_SEARCHTEXT TYPE /AWS1/MPISEARCHTEXT OPTIONAL
    !IT_FILTERS TYPE /AWS1/CL_MPISEARCHFILTER=>TT_SEARCHFILTERLIST OPTIONAL
    !IT_FACETTYPES TYPE /AWS1/CL_MPIFACETTYPELIST_W=>TT_FACETTYPELIST OPTIONAL
    !IV_NEXTTOKEN TYPE /AWS1/MPINEXTTOKEN OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_mpisearchfacetsoutput
  RAISING
    /AWS1/CX_MPIACCESSDENIEDEX
    /AWS1/CX_MPIINTERNALSERVEREX
    /AWS1/CX_MPITHROTTLINGEX
    /AWS1/CX_MPIVLDTNEXCEPTION
    /AWS1/CX_MPICLIENTEXC
    /AWS1/CX_MPISERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Optional arguments:

iv_searchtext TYPE /AWS1/MPISEARCHTEXT /AWS1/MPISEARCHTEXT

The search query text to filter listings before retrieving facets.

it_filters TYPE /AWS1/CL_MPISEARCHFILTER=>TT_SEARCHFILTERLIST TT_SEARCHFILTERLIST

Filters to apply before retrieving facets. Multiple filters are combined with AND logic. Multiple values within the same filter are combined with OR logic.

it_facettypes TYPE /AWS1/CL_MPIFACETTYPELIST_W=>TT_FACETTYPELIST TT_FACETTYPELIST

A list of specific facet types to retrieve. If empty or null, all available facets are returned.

iv_nexttoken TYPE /AWS1/MPINEXTTOKEN /AWS1/MPINEXTTOKEN

If nextToken is returned, there are more results available. Make the call again using the returned token to retrieve the next page.

RETURNING

oo_output TYPE REF TO /aws1/cl_mpisearchfacetsoutput /AWS1/CL_MPISEARCHFACETSOUTPUT

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->searchfacets(
  it_facettypes = VALUE /aws1/cl_mpifacettypelist_w=>tt_facettypelist(
    ( new /aws1/cl_mpifacettypelist_w( |string| ) )
  )
  it_filters = VALUE /aws1/cl_mpisearchfilter=>tt_searchfilterlist(
    (
      new /aws1/cl_mpisearchfilter(
        it_filtervalues = VALUE /aws1/cl_mpisrchfiltvallist_w=>tt_searchfiltervaluelist(
          ( new /aws1/cl_mpisrchfiltvallist_w( |string| ) )
        )
        iv_filtertype = |string|
      )
    )
  )
  iv_nexttoken = |string|
  iv_searchtext = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_nonnegativecount = lo_result->get_totalresults( ).
  LOOP AT lo_result->get_listingfacets( ) into ls_row.
    lv_key = ls_row-key.
    LOOP AT ls_row-value into lo_row_1.
      lo_row_2 = lo_row_1.
      IF lo_row_2 IS NOT INITIAL.
        lv_nonemptystring = lo_row_2->get_value( ).
        lv_nonemptystring = lo_row_2->get_displayname( ).
        lv_nullablestring = lo_row_2->get_parent( ).
        lv_nonnegativecount = lo_row_2->get_count( ).
      ENDIF.
    ENDLOOP.
  ENDLOOP.
  lv_nexttoken = lo_result->get_nexttoken( ).
ENDIF.

Get facets for machine learning category

Retrieve available facet values for listings in the machine learning category

DATA(lo_result) = lo_client->searchfacets(
  it_facettypes = VALUE /aws1/cl_mpifacettypelist_w=>tt_facettypelist(
    ( new /aws1/cl_mpifacettypelist_w( |FULFILLMENT_OPTION_TYPE| ) )
    ( new /aws1/cl_mpifacettypelist_w( |PRICING_MODEL| ) )
  )
  it_filters = VALUE /aws1/cl_mpisearchfilter=>tt_searchfilterlist(
    (
      new /aws1/cl_mpisearchfilter(
        it_filtervalues = VALUE /aws1/cl_mpisrchfiltvallist_w=>tt_searchfiltervaluelist(
          ( new /aws1/cl_mpisrchfiltvallist_w( |machine-learning| ) )
        )
        iv_filtertype = |CATEGORY|
      )
    )
  )
  iv_searchtext = |analytics|
).

Get facets with term and rating range filters

Retrieve facets for security listings with ratings between 3.0 and 5.0 stars

DATA(lo_result) = lo_client->searchfacets(
  it_facettypes = VALUE /aws1/cl_mpifacettypelist_w=>tt_facettypelist(
    ( new /aws1/cl_mpifacettypelist_w( |PRICING_MODEL| ) )
    ( new /aws1/cl_mpifacettypelist_w( |AVERAGE_CUSTOMER_RATING| ) )
  )
  it_filters = VALUE /aws1/cl_mpisearchfilter=>tt_searchfilterlist(
    (
      new /aws1/cl_mpisearchfilter(
        it_filtervalues = VALUE /aws1/cl_mpisrchfiltvallist_w=>tt_searchfiltervaluelist(
          ( new /aws1/cl_mpisrchfiltvallist_w( |security| ) )
        )
        iv_filtertype = |CATEGORY|
      )
    )
    (
      new /aws1/cl_mpisearchfilter(
        it_filtervalues = VALUE /aws1/cl_mpisrchfiltvallist_w=>tt_searchfiltervaluelist(
          ( new /aws1/cl_mpisrchfiltvallist_w( |3.0| ) )
        )
        iv_filtertype = |MIN_AVERAGE_CUSTOMER_RATING|
      )
    )
    (
      new /aws1/cl_mpisearchfilter(
        it_filtervalues = VALUE /aws1/cl_mpisrchfiltvallist_w=>tt_searchfiltervaluelist(
          ( new /aws1/cl_mpisrchfiltvallist_w( |5.0| ) )
        )
        iv_filtertype = |MAX_AVERAGE_CUSTOMER_RATING|
      )
    )
  )
).