Response mask

Select only the fields you want from the response's items

Parameters

The customResponseMask parameter allows selecting only the attributes you want from the items in the response.

Name

Type

Is Required ?

Default value

customResponseMask

string

empty string

customResponeMask

The items attributes will be filtered based on the response mask. The syntax is:

  • a,b,c : comma-separated list will select multiple fields

  • a.b.c : path will select a field from its parent

  • a(b,c): sub-selection will select many fields from a parent

  • a.*.c : the star * wildcard will select all items in a field

Example

  • id, product(title, price) will return only the id, the title and the price of the items

Notes

  • If empty, or omitted, all fields will be returned for the items

Response

All responses from XO Search uses the same format. Check API Reference page for a more detailed description of this format.

pageAPI Reference

Usage example

  • Only returns the id, the product title and price

NodeJS / NPM example

import { search } from '@attraqt/search';

const query = 'T-shirt';

search.init({ token: SEARCH_API_TOKEN });

const response = await search.query(query, {
  customResponseMask: 'id, product(title, price)'
});

console.log(response);

HTML example

<script type="text/javascript">
    xo.init({
        search: {
            token: SEARCH_API_TOKEN
        }
    });

    xo.search.query('T-Shirt', {
        customResponseMask: 'id, product(title, price)'
    }).then((response) => {
        console.log(response);
    });
</script>

Last updated