Best Practices for Fields and Facets in NetSuite Commerce

Optimize performance in NetSuite Commerce by using fields and facets efficiently, limiting unnecessary data and enhancing user experience.

·3 min read·View Oracle Docs

TL;DR

This article discusses best practices for managing fields and facets in the NetSuite Item Search API. Optimizing the usage of these elements can significantly improve site performance and deliver a better shopping experience.

Fields and Field Sets

When utilizing the Item Search API, it's crucial to specify relevant fields or field sets. If no fields are specified, the API defaults to returning only the internal IDs of items. For example, when displaying items on a list, fewer fields are preferable compared to a comprehensive view on a Product Detail page. While you can specify individual fields for each request, creating predefined field sets ensures consistency across your application.

Performance Costs of Individual Fields

Be aware that each additional field you request incurs performance costs. Some fields, like Name or Description, are inexpensive to generate, as they are static. Conversely, dynamic fields, such as those representing live stock information, are costlier. Regularly auditing your field sets to include only necessary fields is recommended.

Example Usage of quantityavailable: This field indicates the stock available for a specific item and is essential for Product List and Detail pages. Though it holds significant data, requesting this on existing orders is unnecessary and may degrade performance.

Expensive Fields

FieldUsageField Sets to AvoidReason to Avoid
correlateditems_detailGenerates a list of related item detailsdetails, order, search, typeaheadWorks better for single items, not lists of multiple products.
matrixchilditems_detailRetrieves child items of a specified productorder, search, typeaheadNot needed for product lists; can slow down performance.
itemoptions_detailLists all item options and their valuessearchMay compromise speed if included in wider field sets.
quantityavailableShows live stock statusorderNot relevant for past orders.
quantityavailable_detailProvides breakdown of stock quantitiesorder, search, typeaheadResource-intensive; use Boolean isinstock when possible.

Facets

Facets should also be utilized judiciously. Here are some essential questions to consider:

  • Is the filter genuinely useful for shoppers?
  • How many values will this facet return?
  • What are the item counts per facet value?

An abundance of unique facet options can confuse users and lead to poor performance.

Best Practices

  • Limit total fields across Field Sets, Facet Fields, and Sort Fields to 1200 to prevent search index rebuild failures.
  • Aim to keep facets to a maximum of 40; exceeding this may result in performance degradation.
  • Ensure facet values remain under 1000.
  • Each facet name should be clear and concise, ideally under 200 characters.
  • Add facets only when absolutely necessary.

Remember:

  • Omitting include=facets in your API request can enhance performance by preventing unnecessary facet generation.
  • Use facet.exclude to intentionally skip unneeded facets from the results.

Preventing Facets from Rendering in Search Results

To prevent certain facets from appearing in search results, utilize the facets_facet_browse.tpl template to exclude them. Insert the facets to be excluded in the data-exclude-facets attribute:

html
<div data-view="Facets.FacetedNavigation" data-exclude-facets="commercecategoryname,category,myfacet,myotherfacet"><div>

For users of SuiteCommerce or SuiteCommerce Advanced (2021.2 or later), you can implement the defineSearchMasterOptions() method on the Environment component to manage site-wide defaults for the Item Search API, including facets.

Key Takeaways

  • Optimize field usage to enhance API performance and maintain a smooth user experience.
  • Regularly audit field sets and facets to avoid unnecessary data generation.
  • Maintain a balance between functionality and performance by limiting the number of fields, facets, and facet values.

Frequently Asked Questions (4)

What is the maximum number of facets recommended for optimal SuiteCommerce performance?
It is recommended to limit facets to 40 or fewer to avoid performance degradation in SuiteCommerce.
How can I prevent specific facets from appearing in search results?
To prevent specific facets from rendering, modify the `facets_facet_browse.tpl` template and use the `data-exclude-facets` attribute within the `Facets.FacetedNavigation` child view.
Is there a field limit I should be aware of when configuring facets?
Yes, do not exceed 1200 total fields across Field Sets, Facet Fields, and Sort Fields to prevent the search index rebuild from failing.
How can you optimize API requests involving facets for better performance?
To optimize API requests, avoid including `include=facets` in the URL unless necessary, and utilize `facet.exclude` to omit unnecessary facets when executing requests to the Item Search API.
Source: Best Practices Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Commerce

View all Commerce articles →