Skip to content

Adding Support for New Asset Types

Petteri Karttunen edited this page Jan 27, 2019 · 4 revisions

Which asset types you search for is configurable from GSearch Asset Type configuration. Which you can retrieve back to the user interface, is however dependent on compatible (ResultItemBuilder)[https://github.com/peerkar/liferay-gsearch/blob/master/gsearch-core-api/src/main/java/fi/soveltia/liferay/gsearch/core/api/results/item/ResultItemBuilder.java]. By default, Liferay GSearch supports the following asset types:

  • Web Content
  • File Entry
  • Blogs Entry
  • Wiki Page
  • Knowledge base article
  • Message Board message

Additionally, there's a default result item builder for any new configured asset. If that's not sufficient for displaying your asset properly you have to implement a new ResultItemBuilder component for that asset type.

You can also configure non Liferay assets (in same index) to be searched for and retrieved. With this feature you can introduce external documents in your Liferay search results. There is a sample configuration and ResultItemBuilder for this scenario.

To add support for a new asset type:

  1. Create a new module
  2. Create a service component implementing ResultItemBuilder interface (see samples in core-impl module)
  3. Add localizations in the web module
  4. Add your new type to the asset type selection menu in the Configuration. For example:
[
    {
        "key": "my-new-asset-type",
        "entryClassName": "com.example.model.MyNewAssetType"
    }
]
  1. Deploy the module and refresh the core-impl bundle in case of problems
Clone this wiki locally