When working with Matrix items, ensure that sorting values are consistent between the child and parent records. For fields defined as sortable, define those fields in child items with the same values as defined for the parent items. If values differ, you will see inconsistent sorting results.
For example, suppose you have added a custom field, Best Seller, to your item record. If the value for Best Seller is set on the parent record but the same value is not set on the child records, sorting on Best Seller may not return the parent records in the expected order.
Note that parent items are assigned a sort value defined as the lowest sort field value from amongst their children. The parent items are then sorted according to those selected sort values.
Combine Sort Fields Using Item Search API
Even if the default sort order is by the relevance score, you can manipulate the sort order by using a custom item field along with the relevance field. This is beneficial when two or more items in the search results have the same relevance score, and you want to use another parameter as a tie breaker to display the search results. For example, you could use Most Popular or Best Seller as another parameter.
Since API calls override default settings in NetSuite, you can use an Item Search API request to combine multiple sort fields and display the search results.
For example, suppose you add a custom field, Best Seller (
custitem_best_seller), to your item record to record the best selling item. Enter a value in the custom field on item records, assigning numbers 1 – 10, with 10 being the best selling item. Then, use an Item Search API request to sort by Relevance and Best Seller.
For information on Item Search API, see Item Search API. For the complete list of parameters supported by the Item Search API, see Item Search API Input Parameters.