Liferay's prime objective is to increase its user interface in terms of functionality and features. One of the new feature is Objects. Let's see how to filter and search custom object entries using Liferay Headless APIs.
For this example, we've used Liferay 7.4.3 GA112 version.
What is Liferay "Object" ?
Liferay object is a method of making a custom entity without service builder or deploying the module. You can create customized apps personalized to your company's needs without writing a single line of code using Liferay Objects. This involves creating new fields, connections, operations, relationships, layouts, views, validations, and customized states.
What are the prerequisites?
- Liferay DXP/Portal 7.4
- Basic knowledge of Liferay
- Liferay Objects
- Liferay Objects Headless API
For this example, we have created an entity to manage Dealer information. The following are the attributes that we’ll store for dealers.
Object Name: Dealer

Liferay Object Filtering Techniques
Liferay allows you to filter object records based on specific fields using a variety of operators and functions for complex filtering with different criteria. The available operators include:
- Comparison Operators: eq, ne, lt, le, gt, ge, startswith
- Logical Operators: and, or, not
- Grouping Operators: ()
- String Function contains
Liferay Headless API URL to apply filter for dealer object
- http://localhost:8080/o/api?endpoint=http://localhost:8080/o/c/dealers/openapi.json
In this example, we'll see different cases where you can filter data based on attributes from the Dealers.
- Filter by Name
- Filter by Type
- Filter by Account Number
- Filter by Registration Date
- Filter by Account Expiry Date
- Filter by Dealer Code
- Filter by Model Rate
- Filter by Labor Rate
- Filter by Is Licensed
Filtering with Text and Picklist fields:
Filter by Dealer Name (Text Field)
- ?filter=dealerName eq 'John Doe'

- ?filter=dealerName ne 'John Doe'
- ?filter=contains(dealerName, 'kerl')

- ?filter=startswith(dealerName, 'Jack')

Filter by Dealer Type (Picklist Field)
- ?filter=dealerType eq 'carBroker'
- ?filter=dealerType ne 'carBroker'
- ?filter=contains(dealerType, 'car')
- ?filter=startswith(dealerType, 'Certified')
Note: You can only filter using the key to the picklist options. Liferay doesn't support filtering based on the display name of a picklist value.
Filtering with Encrypted Field:
Filter by Account Number (Encrypted Field)
To use encrypted fields, first you need to add an encryption algorithm and key to your portal properties. After that you can create an encrypted field for your object.
Note: Required Liferay Version: 7.4 U72+ / GA72+
- object.encryption.algorithm=AES
- object.encryption.key=l1AN3oLKGdrLhpEyLBQOrA== (Your Encryption Key)
Supported algorithm values include AES, Blowfish, and DES. Encryption key values must use base64 encoding.
- ?filter=accountNumber eq 'Encrypted account number

Filtering Date fields:
Filter by Registration Date (Date Field)
- ?filter=registrationDate eq 2024-12-11

Filter by Account Expiry Date (DateTime Field)
- ?filter=accountExpiryDate eq 2027-12-31T23:00:00.000Z
- ?filter=accountExpiryDate le 2030-12-31T23:00:00.000Z

Filtering with Numeric and Decimal fields:
Filter with Numeric and Decimal fields:
- ?filter=dealerCode eq 312001
Filter by Model Rate (Decimal Field)
- ?filter=modelRate eq 11.49
- ?filter=modelRate gt 11

Filter by by Labor Rate (Precision Decimal Field)
- ?filter=laborRate ge 10
- ?filter=laborRate eq 10.45
NOTE: You can use other comparison operator's like ne, gt, ge, lt and le with Integer, Long Integer, Decimal, Precision Decimal, Date and Date & Time fields for filtering.
Filtering with Boolean Field:
Filter by Is Licensed (Boolean Field)
- ?filter= isLicensed eq true
- ?filter=isLicensed ne false

Advanced Data filtering with Logical operator and grouping.
- ?filter=dealerType eq 'carBroker' or dealerType eq 'bikeDealer'

- ?filter=dealerType eq 'carBroker' and contains(dealerName, 'john')
- ?filter=(dealerType eq 'carBroker' or dealerType eq 'bikeDealer') and registrationDate eq 2024-12-11
Liferay Object Searching Methods
Liferay's Headless APIs support full-text search for certain fields. Full-text search works best with Text, Rich Text, and Picklist fields, which are enabled for search. It allows you to search across these fields using keywords.
- Text and Rich Text Fields: Apply search by full-text and keywords with these fields.
- Picklist Fields: Apply search for picklist values by their key (not the name)
- Encrypted Fields: Full-text search doesn't apply to encrypted fields
- Numeric and Decimal Fields: You must use exact values rather than searching with partial keywords.

Conclusion
Liferay Objects Headless API provides powerful filtering and search capabilities. You can filter results based on specific field criteria, such as dealer type, account expiry date, or encrypted account numbers. The full-text search functionality provides enhanced search capability to search across multiple fields. This combination of advanced filtering and searching feature enables more dynamic and efficient data management within Liferay DXP.