Filtering and sorting by custom Object Definition fields via /o/search/v1.0/search

Hi everyone,

I’m building a client extension that uses /o/search/v1.0/search to fetch entries from a site scoped custom Object Definition across all scopes. Pagination and global keyword search work perfectly fine.

I am also able to filter and sort by standard system properties like dateCreated, dateModified, and title without any issues. However, I’m stuck when trying to filter or sort by the specific custom fields belonging to my Object Definition (for example, a lastName field). Whenever I attempt to pass a custom field name into the REST sort parameter, it returns an InvalidSortException.

My questions for the community:

  1. Is there any supported syntax or workaround to sort or filter by a custom Object Definition field via /o/search/v1.0/search

  2. Is there an alternative out-of-the-box headless endpoint (other than the site-scoped /o/c/{objectname}/scopes/{siteId}) that supports company-wide / cross-scope queries while allowing OData filtering and sorting on custom object fields?

Any pointers, documentation, or workarounds would be highly appreciated. Thanks!

As /o/search/v1.0/search is meant to search in all kinds of searchable asset types, it is only able to filter by common fields and some type-specific fields at this moment. The list of filter fields is determined by the EntityModel of the API (varies by Q version) and it is documented here: https://learn.liferay.com/w/dxp/integration/headless-apis/search-apis/search-api-basics#filter-fields. We'd need some kind of dynamic entity model and/or a standardized field mapping and indexing for all kinds of Liferay fields to be able to filter by "custom" fields reliably.